Está en la página 1de 2

# EJERCICIO 1

/*
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package ejercicios;

import java.util.Scanner;

/**
*
* @author Sala1-Pc1
*/
public class Ejercicios {

/**
* @param args the command line arguments
*/
public static void main(String[] args) {

int nt,x;
float suma;
System.out.println("Ingrese el numero de terminos");
Scanner sc =new Scanner(System.in);
nt=sc.nextInt();
System.out.println("Ingrese x");
Scanner xy =new Scanner(System.in);
x=xy.nextInt();
suma= Suma(nt,x);
System.out.println("La suma es: "+suma);
}
static float Suma(int n,int x){
int i=1,j=1;
float s=0;
while(i<=n){
j=j*i;
s=s+((float)Math.pow(x,i))/j;
i=i+1;
}
return s;
}
}

EJERCICIO 2
/*
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package ejercicio2;

import java.util.Scanner;

/**
*
* @author Sala1-Pc1
*/
public class Ejercicio2 {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
int n,i=1;
Scanner sc = new Scanner(System.in);
System.out.println("Introduce el n�mero de elementos");
n = sc.nextInt();
sc.close();

while(i<=n){
System.out.print(Fibonacci(i) + ", ");
i++;
}
}

## private static int Fibonacci(int num){

if(num == 0 || num==1)
return num;
else
return Fibonacci(num-1) + Fibonacci(num-2);
}
}

EJERCICIO 3
/*
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package ejercicio3;

/**
*
* @author Sala1-Pc1
*/
public class Ejercicio3 {

/**
* @param args the command line arguments
*/
public static void main(String[] args) {

Primos();
}
static void Primos(){
int i,cont,j;
for (j=10;j<=60;j++){
cont=0;
for(i=1;i<=60;i++){
if(j%i==0)
cont++;
}
if (cont==2)
System.out.print(+j+", ");
}
}
}