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

Home > Numbers
Two Palindromics (Posted on 2024-04-10) Difficulty: 3 of 5
What is the smallest positive integer N such that N+123456 and N+12345678 are both palindromic?

For example, the smallest whole number such that N+1234 and N+123456 are both palindromic is N=975445, since:975445+1234=976679 and 975445+123456=1098901.

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 Computer Solution Comment 1 of 1
Notice the alternating patterns

N N+1 N+123
8 9 131

N     N+12 N+1234
9877 9889 11111

N   N+123 N+12345
786 909 13131

N         N+1234 N+123456
975445 976679 1098901

N      N+12345 N+1234567
78564 90909 1313131

N              N+123456 N+12345678
97543223 97666679 109888901

N N+1234567 N+123456789
7856342 9090909 131313131

----------
for k in range(1,8):
    print('starting', k)
    sa = ''
    sb = ''
    for i in range(1, k+3):
        sb += str(i)
        if i>k:
            continue
        sa += str(i)
    a = int(sa)
    b = int(sb)
    
    for n in range(1,10000000000):
        x = n+a
        sx = str(x)
        if sx != sx[::-1]:
            continue
        y = n+b
        sy = str(y)
        if sy != sy[::-1]:
            continue
        print(a, n, int(x), int(y))
        break
    

Edited on April 10, 2024, 12:43 pm
  Posted by Larry on 2024-04-10 12:39:42

Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


Search:
Search body:
Forums (1)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (6)
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