30 lines
657 B
Text
30 lines
657 B
Text
N = 1000
|
|
for i = 0 to N - 1
|
|
n$ = str$(fibonacci(i))
|
|
j = val(left$(n$,1))
|
|
actual(j) = actual(j) +1
|
|
next
|
|
print
|
|
html "<table border=1><TR bgcolor=wheat><TD>Digit<td>Actual<td>Expected</td><tr>"
|
|
for i = 1 to 9
|
|
html "<tr align=right><td>";i;"</td><td>";using("##.###",actual(i)/10);"</td><td>";using("##.###", frequency(i)*100);"</td></tr>"
|
|
next
|
|
html "</table>"
|
|
end
|
|
|
|
function frequency(n)
|
|
frequency = log10(n+1) - log10(n)
|
|
end function
|
|
|
|
function log10(n)
|
|
log10 = log(n) / log(10)
|
|
end function
|
|
|
|
function fibonacci(n)
|
|
b = 1
|
|
for i = 1 to n
|
|
temp = fibonacci + b
|
|
fibonacci = b
|
|
b = temp
|
|
next i
|
|
end function
|