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

Home > Just Math
How Many 21's (Posted on 2024-09-14) Difficulty: 2 of 5
List all integers from 1 to 999, one after another to form a number

12345678910111213...997998999

How many times does the "21" grouping appear in this number?

No Solution Yet Submitted by Danish Ahmed Khan    
No Rating

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution solution and check Comment 1 of 1
First 21 itself of course. Then x21 where x is 1 through 9. And there's 210 through 219.

There's the less obvious 12 13 combo and 1x2 1x3 where x is 0 through 9.

That's 1 + 9 + 10 + 1 + 10 = 31.

s='';
for i=1:999
  s=[s num2str(i)];
end
f=strfind(s,'21');
length(f)

verifies this answer.

  Posted by Charlie on 2024-09-14 10:52:13
Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


Search:
Search body:
Forums (0)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (2)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

Chatterbox:
Copyright © 2002 - 2024 by Animus Pactum Consulting. All rights reserved. Privacy Information