domingo, 21 de agosto de 2011

FACTORIAL


public class Factorial {
private int n;

public Factorial (int n1) {
this.n=n1;
}

public String getFactorial (int n1) {
int i;
int r = 1;
for(i = 1; i <= n1; i++){
r=r* i;
}
return("El factorial es:" + r);
}

}

iNICIO:


import java.io.*;
public class Inicio {

public static void main (String [] args) throws IOException {
BufferedReader lectura = new BufferedReader(new InputStreamReader (System.in));


int n1;


System.out.println("ingrese numero factorial");
n1=Integer.parseInt(lectura.readLine());

Factorial f=new Factorial(n1);
System.out.println(f.getFactorial(n1));
}
}


No hay comentarios:

Publicar un comentario