Advertisement
Guest User

Untitled

a guest
Jul 20th, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.63 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. class Main {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.  
  7.         long initial = scanner.nextLong();
  8.         long nextToInitial = 0;
  9.  
  10.         int counter = 0;
  11.  
  12.         while (true) {
  13.             nextToInitial = factorial(counter);
  14.  
  15.             if (initial < nextToInitial) {
  16.                 break;
  17.             }
  18.  
  19.             counter++;
  20.         }
  21.  
  22.         System.out.println(counter);
  23.     }
  24.  
  25.     public static long factorial(int n) {
  26.         if (n == 0) {
  27.             return 1;
  28.         }
  29.  
  30.         return n * factorial(n - 1);
  31.     }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement