diff options
author | Jesse Luehrs <doy@tozt.net> | 2009-05-14 19:06:54 -0500 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2009-05-14 19:06:54 -0500 |
commit | 394121b98178246a0b1063e9104f8878cf2a17e5 (patch) | |
tree | 3dd3591a530774c461fd9960b29d664de204c33c /25.bc | |
parent | 7e7b56db42ceb8d2b8973eae678fa4b58d5d3659 (diff) | |
download | projecteuler-394121b98178246a0b1063e9104f8878cf2a17e5.tar.gz projecteuler-394121b98178246a0b1063e9104f8878cf2a17e5.zip |
add solution for problem 25
Diffstat (limited to '25.bc')
-rw-r--r-- | 25.bc | 29 |
1 files changed, 29 insertions, 0 deletions
@@ -0,0 +1,29 @@ +#!/usr/bin/bc + +scale = 20 +phi = (1 + sqrt(5)) / 2 +loglimit = 1000 - 1 + l(sqrt(5))/l(10) + +scale = 0 +n = 1 +min = -1 +max = -1 +while (1) { + print n, " (", min, ", ", max, ")\n" + scale = 20 + if (l(phi^n - (1 - phi)^n)/l(10) > loglimit) { + max = n + } else { + min = n + } + scale = 0 + if (max - min == 1) { + max + halt + } + if (max == -1) { + n *= 2 + } else { + n = (max + min) / 2 + } +} |