Created
May 27, 2011 17:06
-
-
Save johana-star/995698 to your computer and use it in GitHub Desktop.
Euler Project Problem #025
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
# Solution to Project Euler's twenty-fifth problem | |
# http://projecteuler.net/index.php?section=problems&id=10 | |
# Find the term of the first thousand-digit Fibonacci number. | |
i1, i2, count = 1, 1, 2 | |
until i1.to_s.length == 1000 or i2.to_s.length == 1000 | |
i1 = i1 + i2 | |
i2 = i2 + i1 | |
count += 2 | |
end | |
if i1.to_s.length == 1000 then puts "#{i1} whose term is #{count-1}" | |
else puts "#{i2} whose term is #{count}" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment