Euler 25
Project Euler problem 25 is to find the index of the first Fibonacci number of 1000 characters. I used the gmp library – I couldn’t find a way to get the length of a bigz data type so converted it to a string:
library(gmp)
digits <- 0
i <- 0
while (digits < 1000) {
i = i + 1
number.string = as.character(fibnum(i))
digits = nchar(number.string)
}
print(i)
The gmp fibnum function is quick.