Self numbers: Difference between revisions
m
→{{header|AppleScript}}: Edited comments to show limit of accuracy. Changed the indexDiff calculation to reflect what it means (but same results). Added another demo.
m (→{{header|Phix}}: mirrored bugfix) |
m (→{{header|AppleScript}}: Edited comments to show limit of accuracy. Changed the indexDiff calculation to reflect what it means (but same results). Added another demo.) |
||
Line 25:
This connection with significant digit change means every ten blocks form a higher-order block, every ten
of these a higher-order-still block, and so on.
The code below appears to be good up to the last self number before 10^12 — ie. 999,999,999,997, which is
returned as the 97,777,777,792nd such number. After this, instead of zero-length shorter runs, the actual
pattern apparently starts again with a single run of 10, like the one at the beginning.
*)
on selfNumbers(indexRange)
Line 48 ⟶ 52:
on fastForward()
if (counter ≥ startIndex) then return
-- The highest-order blocks whose ends this script
-- The difference between equivalently positioned numbers in these blocks is 100,000,000,001.
-- The figures for successively lower-order blocks
set indexDiff to 9.777777778E+9
set numericDiff to 1.00000000001E+11
Line 59 ⟶ 63:
set currentSelf to (currentSelf + numericDiff)
else
set indexDiff to (indexDiff
set numericDiff to numericDiff div 10 + 1
end if
Line 114 ⟶ 118:
-- One hundred millionth:
selfNumbers(100000000)
--> {1.022727208E+9}
-- 97,777,777,792nd:
selfNumbers(9.7777777792E+10)
--> {9.99999999997E+11}</lang>
=={{header|C}}==
|