Self numbers: Difference between revisions
Content added Content deleted
m (→first 50 self numbers: added/changed whitespace and comments.) |
m (→{{header|Phix}}: updated comments inline with AppleScrpt entry, and removed an over-eagerly inserted 7&0) |
||
Line 903: | Line 903: | ||
-- This connection with significant digit change means every ten blocks form a higher-order block, every ten |
-- 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. |
-- 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. |
|||
-- |
-- |
||
integer startIndex, endIndex, counter |
integer startIndex, endIndex, counter |
||
Line 932: | Line 936: | ||
if doneAfterAdding(11,9) then return output end if |
if doneAfterAdding(11,9) then return output end if |
||
-- If necessary, |
-- If necessary, forward to last self number before the lowest-order block containing first number rqd. |
||
if counter |
if counter<startIndex then |
||
-- The highest-order blocks whose ends this |
-- The highest-order blocks whose ends this handles correctly contain 9,777,777,778 self numbers. |
||
-- The difference between equivalently positioned numbers in these blocks is |
-- The difference between equivalently positioned numbers in these blocks is 100,000,000,001. |
||
-- The figures for successively lower-order blocks |
-- The figures for successively lower-order blocks have successively fewer 7s and 0s! |
||
atom indexDiff = |
atom indexDiff = 9777777778, |
||
numericDiff = |
numericDiff = 100000000001 |
||
while indexDiff>=98 and counter!=startIndex do |
while indexDiff>=98 and counter!=startIndex do |
||
if counter+indexDiff < startIndex then |
if counter+indexDiff < startIndex then |