Guest User

Untitled

a guest
Nov 18th, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. import java.util.Scanner;
  2. public class Factorial{
  3. public static void main(String args[]){
  4. int yourNumber = 0;
  5. Scanner Geoff = new Scanner(System.in);
  6. System.out.println("Give me a number: ");
  7. yourNumber = Geoff.nextInt();
  8. System.out.printf("The factorial of your number is %d", factorial(yourNumber));
  9. }
  10. public static int factorial(int n){
  11. if (n == 1){
  12. return n;
  13. }
  14. else{
  15. return n * factorial(n-1);
  16. }
  17. }
  18. }
Add Comment
Please, Sign In to add comment