Jump to content
BrainDen.com - Brain Teasers
  • 0

Find the number


Guest
 Share

Question

13 answers to this question

Recommended Posts

  • 0

N=9376 N2=87909376

Must love computers

I went further and found the same for 5, 6, 7, 8 and 9 digit numbers as well.

  • 4 N=9376 N2=87909376
  • 5 N=83647 N2=2147483647
  • 6 N=483647 N2=2147483647
  • 7 N=7483647 N2=2147483647
  • 8 N=47483647 N2=2147483647
  • 9 N=147483647 N2=2147483647

Here is the java code I wrote to find it, took about 1 min


public static void main(String[] args) {


  for (int n=1000; n<= 999999999; n++) {

   int n2 = (int) Math.pow(n, 2);

   String ns = String.valueOf(n);

   String n2s = String.valueOf(n2);

   if (n2s.lastIndexOf(String.valueOf(n)) == (n2s.length() - ns.length() ) ) {

    System.out.println(ns.length()+" N="+n+" N2="+n2);

   }

  }

}

Edited by bendigi
Link to comment
Share on other sites

  • 0

You are right Captain Ed, I had a booboo in my code, I forgot about int's max, changed it to long type and there is the latest results

It's interesting when n is 6, 7 and 8, there are actually two answers for this puzzle.

  • 4 N=9376 N2=87909376
  • 5 N=90625 N2=8212890625
  • 6 N=109376 N2=11963109376
  • 6 N=890625 N2=793212890625
  • 7 N=2890625 N2=8355712890625
  • 7 N=7109376 N2=50543227109376
  • 8 N=12890625 N2=166168212890625
  • 8 N=87109376 N2=7588043387109376
  • 9 N=787109376 N2=619541169787109376

And the latest Code:


	public static void main(String[] args) {


		for (int n=1000; n<= 999999999; n++) {

			long n2 = (long) Math.pow(n, 2);

			String ns = String.valueOf(n);

			String n2s = String.valueOf(n2);

			if (n2s.lastIndexOf(ns) == (n2s.length() - ns.length() ) ) {

				System.out.println(ns.length()+" N="+n+" N2="+n2);

			}

		}

	}

BTW, I am not able to edit my original post more than 3 times ?

Edited by bendigi
Link to comment
Share on other sites

  • 0

Yeah!!

9376 is the answer!!

I made a java program to find it. Check it out:-

int i=1000,n=0,a;

for(i=1000;i<=9999;i++)

{

n=i*i;

a=n/10000;

a=a*10000;

a=n-a;

if(a==i)

{

System.out.println(i);

System.exit(0);

}

}

Edited by VampBrain
Link to comment
Share on other sites

  • 0

Last digit can be

a. 0

b. 1

c. 5

d. 6

We will take them one by one.

a) If we have 0 at last, then even if we have anything before it, it will keep on giving 00 at last, again if we have 00 at last it will keep giving 0000 at last and so on. So, ruling out 0 as last digit.

b) If we have 1 at last, we cant have anything before tha so that its square gives same last 2 digit.

i.e: 11*11 = 121, 21*21 =441 and so on. So, ruling out 1 also.

c) If we have 5 as last digit, we have only 25*25 = 625(i.e: Last 2 digits are same).

Going ahead, we can find that (x00 + 25) * (x00 + 25) = yz0000 + 50 * x00 + 625 , so we can have x=6.

Now, 625*625 = 390625

Going forward, (x000 + 625) * (x000 + 625) = yz000000 + 1250 * x000 + 390625, we cant have 0 at 4th place, so this option is ruled out.

d) 6 as last digit

(x0 + 6) * (x0 + 6) = yz00 + 36 * x0 + 36.

We can find out that only x=7 satisfies the condition for last 2 digit to be same. 76 * 76 = 5776

Similarly, we can find that digit at hundreth place should be, 3( 376 * 376 = 141376)

and digit at thousanth place should be 9

(9376 * 9376 = 87909376)

9376 : 87909376

Link to comment
Share on other sites

  • 0

n2 ends in n and n is 4 digit number.

This means that,

n2 = 10000x + n

n(n-1) = 10000x

Now, either n or n-1 must be a multiple of 54 (625) and the other number must be a multiple of 24 (16)

Now take all 4 digit multiples of 625 that are odd. there are only 7. Now consider numbers +1 of these numbers and divide them by 16. You don't need to consider -1 of these numbers as they would end in 4 and the square of this number would end in 6.

Of these 7 numbers, there is only one that is divisible by 16. Not surprisingly it is 9376. So, this is the number you are looking for.

You can use this method for any number of digits of "n".

Edited by DeeGee
Link to comment
Share on other sites

  • 0

Could not edit the above post but there is a correction to be made. You need to check the the -1 numbers for divisibility as well. Although it does not make a difference for 4 digit numbers, for higher digit numbers it will be needed.

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...