All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars
 perplexus dot info

 Square String Settlement (Posted on 2010-01-28)
All the positive perfect squares 1, 4, 9, 16, 25.... are written in strictly ascending order of magnitude and without the commas and spaces, resulting in the following infinite string:

149162536496481100121144......

Reading left to right, what is the 2010th digit in the above pattern?

 See The Solution Submitted by K Sengupta Rating: 3.0000 (1 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
 re: Computer verification | Comment 4 of 8 |
(In reply to Computer verification by Jim Keneipp)

In QuickBasic I get a 4 when executing

YEAR = 2010

FOR i = 1 TO 1000
s\$ = s\$ + STR\$(i ^ 2)
IF LEN(s\$) >= YEAR THEN EXIT FOR
NEXT i

PRINT MID\$(s\$, YEAR, 1)
END

because of the space that STR\$() gives as the first byte of the string

YEAR = 2010

FOR i = 1 TO 1000
s\$ = s\$ + LTRIM\$(STR\$(i ^ 2))
IF LEN(s\$) >= YEAR THEN EXIT FOR
NEXT i

PRINT MID\$(s\$, YEAR, 1)
END

gives the correct 6.

What version of Basic are you using?

 Posted by Charlie on 2010-01-28 14:24:29

 Search: Search body:
Forums (0)