Advertisement
ogv

Untitled

ogv
Aug 11th, 2019
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.22 KB | None | 0 0
  1. class Solution {
  2.     public int fib(int N) {
  3.         if (N == 1) return 1;
  4.        
  5.         double ϕ = (Math.sqrt(5) + 1)/2;
  6.         return (int)Math.round((Math.pow(ϕ, N) - Math.pow(ϕ, -N))/Math.sqrt(5));
  7.     }    
  8. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement