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

Home > Numbers
Center Six Digits (Posted on 2023-07-15) Difficulty: 3 of 5
A 6-digit positive integer N is squared to form a 12-digit number. The center six digits of N^2 constitute N. Determine all possible values of N.

(If 'abcdef' was the 6-digit number, then the 12-digit number would look like 'uvwabcdefxyz'.)

Will there be any further solution(s) if N contained a leading zero?

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

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution Solution two ways | Comment 1 of 3
Method One:  analytic assist
6-digit number is N
12-digit number is the concatenation ANB where A and B are 3-digit numbers
N^2 = A*10^9 + 1000N + B
N^2 - 1000N - (A*10^9 + B) = 0
N = 500 ± [sqrt (10^6 + 4*A*10^9 + 4B)]/2
N = 500 ± [sqrt (250000 + A*10^9 + B)]
reject the - option because then N<0
N = 500 + sqrt (250000 + A*10^9 + B)

The first method goes through all possible values of A and B, calculates N from Pythagorean theorem then checks if first 3 and last 3 characters of N^2 are A and B.  With these constraints, rejecting non integer values of N was not necessary.

There are four solutions, letting n have leading zeros did not add any:
A    B   N    N^2
0 0 1000 1000000            rejected; N^2 not a 12 digit number
141 0 376000 141376000000
245 625 495475 245495475625
390 0 625000 390625000000
943 724 971582 943971582724

Method Two:
Make a list of all 12 digit squares; check if middle 6 squared is the same
Output of second program:
376000 141376000000
495475 245495475625
625000 390625000000
971582 943971582724

-----------
for a in range(1000):
    for b in range(1000):
        n = 500 + (250000 + a*10**9 + b)**.5
        # if n%1 != 0:
        #     continue
        nsqr = n*n
        if nsqr%1000 != b or int(nsqr/10**9) != a:
            continue
        print(a,b,int(n), int(n**2))
        
squares = [i*i for i in range(316228, 1000000)]

for s in squares:
    n = int(str(s)[3:9])
    if n*n == s:
        print(n,s)

  Posted by Larry on 2023-07-15 07:57:26
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 (10)
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