Jump to content

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 is thought to handlehandles correctly contain 9,777,777,778 self numbers.
-- The difference between equivalently positioned numbers in these blocks is 100,000,000,001.
-- The figures for successively lower-order blocks are obtained byhave successively removingfewer 7s and 0s!
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 div+ 102) +div 110
set numericDiff to numericDiff div 10 + 1
end if
Line 114 ⟶ 118:
-- One hundred millionth:
selfNumbers(100000000)
--> {1.022727208E+9}</lang>
 
-- 97,777,777,792nd:
selfNumbers(9.7777777792E+10)
--> {9.99999999997E+11}</lang>
 
=={{header|C}}==
557

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.