practica 5
Post on 07-Jul-2015
39 Views
Preview:
DESCRIPTION
TRANSCRIPT
UNIVERSIDAD NACIONAL DE CHIMBORAZO
FACULTAD DE CIENCIAS DE LA EDUCACION HUMANAS Y
TECNOLOGIAS
NOMBRE: GEOVANNY YUNGAN
PRACTICA 5
EJERCICIO 1
Generar la siguiente serie:
2, 4, 8, 16, 32, 64, 128, 256, .
import java.util.Scanner;
class practica5 {
public static void main(String[] args) {
Scanner datos = new Scanner(System.in);
int n,a,r,i;
System.out.println ("***Serie del 2*** ");
System.out.print ("Ingrese la Cantidad de numeros a calcular: ");
n = datos.nextInt ();
r=0;
for(i=1;i<=n;i++){
r=r+1;
a=(int) Math.pow(2,r);
System.out.print ( + a+ "," );
}
}
}
EJECUCION
EJERCICIO 2
Generar la siguiente serie:
3, 9, 27, 81, 243, 729, 2187,.
import java.util.Scanner;
class SERIE3 {
public static void main(String[] args) {
Scanner datos = new Scanner(System.in);
int n,a,r,i;
System.out.println ("*****Serie del 3:**** ");
System.out.print ("Ingrese la Cantidad de numeros a calcular: ");
n = datos.nextInt ();
r=0;
for(i=1;i<=n;i++){
r=r+1;
a=(int) Math.pow(3,r);
System.out.print ( + a+ "," );
}
}
}
EJECUCION
top related