Created
March 2, 2017 19:36
-
-
Save blackknight36/30d2c97f2be5157807a091baa8970748 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
#!/usr/bin/env ruby | |
def fiboMod (t1, t2, n) | |
n = n-1 | |
if n == 1 | |
return t2 | |
else | |
return fiboMod(t2, t2**2 + t1, n) | |
end | |
end | |
t1, t2, n = gets.strip.split.map {|i| i.to_i } | |
puts fiboMod(t1, t2, n) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment