Advertisement
Guest User

Untitled

a guest
Mar 25th, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Solution {
  4.  
  5. private static int fact(int num, double gn) {
  6. double res = (num * Math.log10(gn)) -
  7. ((Math.log10(5)) / 2);
  8. return (int)Math.ceil(res);
  9. }
  10.  
  11. public static void main(String[] args) {
  12. try (Scanner sc = new Scanner(System.in)) {
  13. int T = sc.nextInt();
  14. double goldenNumber = (1 + Math.sqrt(5)) / 2;
  15. while(T-- > 0) {
  16. int N = sc.nextInt();
  17. int g = 1;
  18. int j;
  19. for(j = 0; g != N; j++) {
  20. g = fact(j, goldenNumber);
  21. }
  22. System.out.println(j - 1);
  23. }
  24. }
  25. }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement