Advertisement
Guest User

Untitled

a guest
Apr 26th, 2017
43
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. /*
  2. * To change this license header, choose License Headers in Project Properties.
  3. * To change this template file, choose Tools | Templates
  4. * and open the template in the editor.
  5. */
  6. package factorial;
  7. import java.util.Scanner;
  8. /**
  9. *
  10. * @author Avδρέας
  11. */
  12. public class Factorial {
  13.  
  14. /**
  15. * @param args the command line arguments
  16. */
  17. public static void main(String[] args) {
  18. // variables a pedir al usuario
  19. Scanner datos = new Scanner(System.in);
  20. //declaracion de variables
  21. int fac=1, i=1, lim=0;
  22. //solicitud de variable al usuario
  23. System.out.println("ingres el numero");
  24. lim=datos.nextInt();
  25. //ciclo while
  26. while(i<=lim){
  27. //realizacion de la operacion
  28. fac=fac*i;
  29. i++;
  30. }
  31. System.out.println("el factorial de: "+ lim +" es igual a: "+ fac);
  32.  
  33.  
  34. }
  35.  
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement