Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The Millionth Fibonacci Kata #20

Open
houjunchen opened this issue Jun 10, 2016 · 2 comments
Open

The Millionth Fibonacci Kata #20

houjunchen opened this issue Jun 10, 2016 · 2 comments

Comments

@houjunchen
Copy link

In this kata you will have to calculate fib(n) where:

fib(0) := 0
fib(1) := 1
fin(n + 2) := fib(n + 1) + fib(n)

Write an algorithm that can handle n where 1000000 ≤ n ≤ 1500000.

Your algorithm must output the exact integer answer, to full precision. Also, it must correctly handle negative numbers as input.

HINT I: Can you rearrange the equation fib(n + 2) = fib(n + 1) + fib(n) to find fib(n) if you already know fin(n + 1) and fib(n + 2)? Use this to reason what value fib has to have for negative values.

HINT II: See http://mitpress.mit.edu/sicp/chapter1/node15.html


計算費式數列,參數可為負數。

提示1:在已知 fin(n + 1)fib(n + 2) 的情況下,透過重新排列 fib(n + 2) = fib(n + 1) + fib(n) 就可以推算出 n 為負數時的值。
提示2:http://mitpress.mit.edu/sicp/chapter1/node15.html (用矩陣公式解)。

https://www.codewars.com/kata/the-millionth-fibonacci-kata

@houjunchen
Copy link
Author

Pass

1 similar comment
@bucker
Copy link

bucker commented Jun 14, 2016

Pass

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants