25 lines
698 B
Text
25 lines
698 B
Text
HOW TO RETURN fibonacci.numbers n:
|
|
PUT 1, 1 IN a, b
|
|
PUT {} IN fibo
|
|
FOR i IN {1..n}:
|
|
INSERT a IN fibo
|
|
PUT b, a+b IN a, b
|
|
RETURN fibo
|
|
|
|
HOW TO RETURN digit.distribution nums:
|
|
PUT {} IN digits
|
|
FOR i IN {1..9}: PUT i IN digits["`i`"]
|
|
PUT {} IN dist
|
|
FOR i IN {1..9}: PUT 0 IN dist[i]
|
|
FOR n IN nums:
|
|
PUT digits["`n`"|1] IN digit
|
|
PUT dist[digit] + 1 IN dist[digit]
|
|
FOR i IN {1..9}:
|
|
PUT dist[i] / #nums IN dist[i]
|
|
RETURN dist
|
|
|
|
PUT digit.distribution fibonacci.numbers 1000 IN observations
|
|
|
|
WRITE "Digit"<<6, "Expected">>10, "Observed">>10/
|
|
FOR d IN {1..9}:
|
|
WRITE d<<6, ((10 log (1 + 1/d))>>10)|10, observations[d]>>10/
|