Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Solution {
- private static int fact(int num, double gn) {
- double res = (num * Math.log10(gn)) -
- ((Math.log10(5)) / 2);
- return (int)Math.ceil(res);
- }
- public static void main(String[] args) {
- try (Scanner sc = new Scanner(System.in)) {
- int T = sc.nextInt();
- double goldenNumber = (1 + Math.sqrt(5)) / 2;
- while(T-- > 0) {
- int N = sc.nextInt();
- int g = 1;
- int j;
- for(j = 0; g != N; j++) {
- g = fact(j, goldenNumber);
- }
- System.out.println(j - 1);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement