Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/luissantiagodev/factorial
- Owner: luissantiagodev
- License: apache-2.0
- Created: 2016-11-12T20:51:24.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2016-11-12T21:00:38.000Z (about 8 years ago)
- Last Synced: 2024-11-14T09:34:19.256Z (2 months ago)
- Topics: java
- Homepage:
- Size: 5.86 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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);
}
}