Skip to content

Instantly share code, notes, and snippets.

@blackknight36
Created March 2, 2017 19:36
Show Gist options
  • Save blackknight36/30d2c97f2be5157807a091baa8970748 to your computer and use it in GitHub Desktop.
Save blackknight36/30d2c97f2be5157807a091baa8970748 to your computer and use it in GitHub Desktop.
#!/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