Created
November 24, 2016 06:57
-
-
Save AlexRomanofff/14d48787ee4d4df4ab2a2f7d2886e2c6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package homework; | |
import java.util.Scanner; | |
public class Factorial { | |
public static void main(String[] args) { | |
Scanner sc = new Scanner(System.in); | |
System.out.println("input number from 4 to 12"); | |
int a = sc.nextInt(); | |
if (a < 4 || a > 12) { | |
System.out.println("wrong input number!!!"); } | |
else { | |
System.out.println(calcFactorial(a)); | |
} | |
} | |
public static long calcFactorial(int a) { | |
long fact=1; | |
for(int i=1; i<=a; i++) { | |
fact=fact*i; | |
} | |
return fact; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment