[ prog / sol / mona ]

prog


e and the Stern-Brocot tree

44 2021-02-28 11:54

The phi stream grows much faster in numerator and denominator digit counts, since they are essentially the fibs, and by stream index 10^9 we are already past 200 million.

$ gawk '{ if (length ($0) < 1000) { print NR ": " $0 } else { print NR "! " length ($0) } }' phi9.txt
1:  group Expo (Fixed RL, 500000000)
2: target 1.618033988749895
3: result 1.618033988749895
4! 208987641
5! 208987641
6: stack 6

The e stream was still just a little over 6 million digits >>43 at a thousand times the stream index. For verification here is the hash of the phi 10^9 numerator:

$ sha1sum <(gawk 'NR == 4 { printf "%s", $0 }' phi9.txt)
4a74c3993775189c754cfcc6ecf5de166bb718c7  /dev/fd/63

And the hash of the denominator:

$ sha1sum <(gawk 'NR == 5 { printf "%s", $0 }' phi9.txt)
24e5e3350b839eea494e9daec46eec323f0f32dd  /dev/fd/63
54


VIP:

do not edit these