Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/luissantiagodev/factorial

Introduce un numero positivo y sacara el factorial respecto al numero ingresado
https://github.com/luissantiagodev/factorial

java

Last synced: 7 days ago
JSON representation

Introduce un numero positivo y sacara el factorial respecto al numero ingresado

Awesome Lists containing this project

README

        

#Factorial

import java.util.Scanner;

public class Activity {

public static void main(String[] args) {

Scanner input=new Scanner(System.in);
int factorial;

System.out.println("introduzca un numero para sacar el vectorial");
factorial= input.nextInt();



while(factorial<0){

System.out.println("ERROR, INTRODUZCA UN NUMERO POSITIVO");
System.out.println("Introduce un numero positivo");
factorial= input.nextInt();
}

int factorial2 = 1;
for (int i = 1; i<=factorial; i++)
{
factorial2= factorial2*i;


}

System.out.println("factorial de "+factorial+" : "+factorial2);







}
}