All the positive triangular numbers are written successively without commas or spaces resulting in this infinite string.
13610152128364555667891105120136153171..............
Determine the 2010th digit in the above pattern.
DEFDBL A-Z
sought = 2010
FOR i = 1 TO 1000
diff = diff + 1
tr = tr + diff
t$ = LTRIM$(STR$(tr))
PRINT t$
prevCt = ct
ct = ct + LEN(t$)
IF ct >= sought THEN
d$ = MID$(t$, sought - prevCt, 1)
PRINT diff; d$: END
END IF
NEXT
finds as the last couple of lines of its output:
97903
442 3
meaning that the sought digit is 3, being the last digit of the 442nd triangular number, 97903.
|
Posted by Charlie
on 2010-07-20 13:50:02 |