Created
August 10, 2020 10:56
-
-
Save 0xkohe/f0562f7b847dab43a2a5e5f1b274a7cb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func fibExp(t fibNum, n int) fibNum { | |
r := t | |
// 1 | |
a := fibNum{num: big.NewRat(1, 1), numMultipliedBySR: big.NewRat(0, 999)} | |
for n > 1 { | |
if n%2 == 1 { | |
a = fibMul(a, r) | |
} | |
r = fibMul(r, r) | |
n = n / 2 | |
} | |
return fibMul(r, a) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment