Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package factorial;
- import java.util.Scanner;
- /**
- *
- * @author Avδρέας
- */
- public class Factorial {
- /**
- * @param args the command line arguments
- */
- public static void main(String[] args) {
- // variables a pedir al usuario
- Scanner datos = new Scanner(System.in);
- //declaracion de variables
- int fac=1, i=1, lim=0;
- //solicitud de variable al usuario
- System.out.println("ingres el numero");
- lim=datos.nextInt();
- //ciclo while
- while(i<=lim){
- //realizacion de la operacion
- fac=fac*i;
- i++;
- }
- System.out.println("el factorial de: "+ lim +" es igual a: "+ fac);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement