3 ms·
Ok, here is my solution in Java. BigInt makes things simple and there is no need for memoization. public void test25() { BigInt f1 = new B
by huherto 17y ago
Ok, here is my solution in Java. BigInt makes things simple and there is no need for memoization.
public void test25() {
BigInt f1 = new BigInt(0);
BigInt f2 = new BigInt(1);
BigInt f3 = null;
int i = 2;
while(true) {
f3 = f1.add(f2);
f1 = f2;
f2 = f3;
if (f3.toString().length() >= 1000)
break;
i++;
}
res("25", 4782, i);
}
- vito 17y agoDid it in Io (was already doing Euler stuff), pretty similar: problem25 := method(digits, term := 0 n0 := BigNum with(0) n1 := BigNum with(1) loop( n0 = n0 + n1 n1 = n0 - n1 if(n1 asString size >= digits, break) term = term + 1 ) term ) problem25(1000) println
- deleted 17y ago[deleted]
- huherto 17y agonice!