Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Solution {
- public int fib(int N) {
- if (N == 1) return 1;
- double ϕ = (Math.sqrt(5) + 1)/2;
- return (int)Math.round((Math.pow(ϕ, N) - Math.pow(ϕ, -N))/Math.sqrt(5));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement