Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- class Main {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- long initial = scanner.nextLong();
- long nextToInitial = 0;
- int counter = 0;
- while (true) {
- nextToInitial = factorial(counter);
- if (initial < nextToInitial) {
- break;
- }
- counter++;
- }
- System.out.println(counter);
- }
- public static long factorial(int n) {
- if (n == 0) {
- return 1;
- }
- return n * factorial(n - 1);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement