Jump to content
BrainDen.com - Brain Teasers
  • 0


Guest
 Share

Question

The square of each of the base ten positive integers from 1 to 2010 inclusively are written successively without commas or spaces, resulting in the following pattern:

14916253649............4040100

Determine the total number of times that the digit 9 appear in the abovementioned pattern.

Edited by K Sengupta
Link to comment
Share on other sites

5 answers to this question

Recommended Posts

  • 0

function getIntegerCountFromSquaredSequence(num, range_min, range_max) {

var n_count = 0;

for(var i=range_min;i <= range_max;i++) {

var s_temp = (i * i).toString();

for(var j=0;j<s_temp.length;j++) {

if (s_temp.charAt(j)==num.toString()) {

n_count++;

}

}

}

return n_count;

}

alert(getIntegerCountFromSquaredSequence(9, 1, 2010));

The previous poster was correct.

Link to comment
Share on other sites

  • 0

Very neat, but I'm waiting for the intended mathematical, rather than programmatic, solution from KS.

My weak number theory knowledge expired 20yrs ago, so I'm not even going to attempt it!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...