# A really weird kind of number

About two months ago, I was randomly using my calculator to find a bunch of squares. Then, I noticed something a bit odd. One of the squares was 69696, and I was pretty sure that its square root wasn't a palindrome. When I square-rooted it, I got 264. By now I was really interested. I started experimenting to see if I could find other non-palindromes with palindromic squares, and I found 4!

26, whose square is 676. 264, whose square is 69696. 2285, whose square is 5221225. 2636, whose square is 6948496.

I checked all the way up to 7000^2, but didn't find any more. Maybe I could try writing some code to find them. If you find any, can you put them in the comments? Extra bonus if they're prime!

Note by Kent Hitchborn
2 weeks, 6 days ago

This discussion board is a place to discuss our Daily Challenges and the math and science related to those challenges. Explanations are more than just a solution — they should explain the steps and thinking strategies that you used to obtain the solution. Comments should further the discussion of math and science.

When posting on Brilliant:

• Use the emojis to react to an explanation, whether you're congratulating a job well done , or just really confused .
• Ask specific questions about the challenge or the steps in somebody's explanation. Well-posed questions can add a lot to the discussion, but posting "I don't understand!" doesn't help anyone.
• Try to contribute something new to the discussion, whether it is an extension, generalization or other idea related to the challenge.

MarkdownAppears as
*italics* or _italics_ italics
**bold** or __bold__ bold
- bulleted- list
• bulleted
• list
1. numbered2. list
1. numbered
2. list
Note: you must add a full line of space before and after lists for them to show up correctly
paragraph 1paragraph 2

paragraph 1

paragraph 2

[example link](https://brilliant.org)example link
> This is a quote
This is a quote
    # I indented these lines
# 4 spaces, and now they show
# up as a code block.

print "hello world"
# I indented these lines
# 4 spaces, and now they show
# up as a code block.

print "hello world"
MathAppears as
Remember to wrap math in $$ ... $$ or $ ... $ to ensure proper formatting.
2 \times 3 $2 \times 3$
2^{34} $2^{34}$
a_{i-1} $a_{i-1}$
\frac{2}{3} $\frac{2}{3}$
\sqrt{2} $\sqrt{2}$
\sum_{i=1}^3 $\sum_{i=1}^3$
\sin \theta $\sin \theta$
\boxed{123} $\boxed{123}$

Sort by:

  1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 n n^2 1 1 2 4 2 is PRIME! 3 9 3 is PRIME! 11 121 11 is PRIME! 22 484 26 676 101 10201 101 is PRIME! 111 12321 121 14641 202 40804 212 44944 264 69696 307 94249 307 is PRIME! 836 698896 1001 1002001 1111 1234321 2002 4008004 2285 5221225 2636 6948496 10001 100020001 10101 102030201 10201 104060401 11011 121242121 11111 123454321 11211 125686521 20002 400080004 20102 404090404 22865 522808225 24846 617323716 30693 942060249 100001 10000200001 101101 10221412201 110011 12102420121 111111 12345654321 200002 40000800004 798644 637832238736 1000001 1000002000001 1001001 1002003002001 1002001 1004006004001 1010101 1020304030201 1011101 1022325232201 1012101 1024348434201 1042151 1086078706801 1100011 1210024200121 1101011 1212225222121 1102011 1214428244121 1109111 1230127210321 1110111 1232346432321 1111111 1234567654321 1270869 1615108015161 2000002 4000008000004 2001002 4004009004004 2012748 4051154511504 2294675 5265533355625 3069307 9420645460249 (and most likely infinitely many more solutions...) 

- 2 weeks, 6 days ago

I believe the problem required the square roots to be non-palindromic. Filtering for this would result in the following:

  1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 n n^2 2 4 2 is PRIME! 3 9 3 is PRIME! 26 676 264 69696 307 94249 307 is PRIME! 836 698896 2285 5221225 2636 6948496 22865 522808225 24846 617323716 30693 942060249 798644 637832238736 1042151 1086078706801 1270869 1615108015161 2012748 4051154511504 2294675 5265533355625 3069307 9420645460249 

- 2 weeks, 5 days ago

As always, It was so satisfying seeing the output😄

- 2 weeks, 3 days ago

 1 1 2 4 3 9 11 121 22 484 26 676 101 10201 111 12321 121 14641 202 40804 212 44944 264 69696 307 94249 836 698896 1001 1002001 1111 1234321 2002 4008004 2285 5221225 2636 6948496 10001 100020001 10101 102030201 10201 104060401 11011 121242121 11111 123454321 11211 125686521 20002 400080004 20102 404090404 22865 522808225 24846 617323716 30693 942060249 100001 10000200001 101101 10221412201 110011 12102420121 111111 12345654321 200002 40000800004 798644 637832238736 1000001 1000002000001 1001001 1002003002001 1002001 1004006004001 1010101 1020304030201 1011101 1022325232201 1012101 1024348434201 1042151 1086078706801 1100011 1210024200121 1101011 1212225222121 1102011 1214428244121 1109111 1230127210321 1110111 1232346432321 1111111 1234567654321 1270869 1615108015161 2000002 4000008000004 2001002 4004009004004 2012748 4051154511504 2294675 5265533355625 3069307 9420645460249 10000001 100000020000001 10011001 100220141022001 10100101 102012040210201 10111101 102234363432201 11000011 121000242000121 11011011 121242363242121 11100111 123212464212321 11111111 123456787654321 11129361 123862676268321 12028229 144678292876441 12866669 165551171155561 20000002 400000080000004 30001253 900075181570009

- 2 weeks, 3 days ago

64030648 4099923883299904

110091011 12120030703002121

111091111 12341234943214321 (this one is very interesting because 1109111 also is in the sequence so maybe we can make one generator using this?)

306930693 94206450305460249

- 2 weeks, 3 days ago

Oh great idea! But how?

- 2 weeks, 3 days ago

I thought the pattern repeats it doesn’t seem too, just a coincidence, it messes up the middle part, the ends are palindromic, it’s kinda semi palindromic

- 2 weeks, 3 days ago

- 2 weeks, 3 days ago

I'm starting a new thread bcz that one was getting thinner

@Jason Gomez Here's what we are reqd to do in the program:

Ok lemme strt frm the starting ,

Step 1: know that the number of digits in a number can be calculated by $\boxed{⌊log_{10}n⌋+1}$ here's the logic behind it and do lemme know if u don't understand it.

step 2: we have to create a palindromic square, so for that we will first take a no. (n) then reverse it(save it as r) and at last concatenate them to get the palindromes by setting a loop.

Step 3: filter out squares from the above palindrome set.

Step 4: filter out palindromic squares whose squareroots aren't palindromes.

Hope you got it

Regards, Agent T

- 2 weeks, 3 days ago

So you are trying to get palindromes first then take the square root and then check whether the resulting number is non palindromic, effectively going the opposite way which should speed up things, that’s a good method, this method only gets even number of digits palindromic square numbers, a little tweak and odd digits should be done too,

- 2 weeks, 2 days ago

I always strt with a longer but easier way then modify to make it more efficient, and yes you're correct about the nos.having odd no of digits (n.h.o.n.d) But I think if we are able to make one for n.h.e.n.d. then adding a no.in the middle to make it a n.h.o.n.d. would be a piece of cake :)

- 2 weeks, 2 days ago

Few things to note, numbers ending in zero can not be palindromic, after taking root to check whether an integer is formed you can use int(n)==n, works till about n=67000000, so all square palindromes under fourteen digits can be found using this, beyond this requires the remaking of the square root function

- 2 weeks, 2 days ago

Okay cool I'll keep taht in mind

- 2 weeks, 2 days ago

836.0 698896

798644.0 637832238736

64030648.0 4099923883299904

These are the only even palindromic squares I got it (outputted one more after this 100000000.0 9999999999999999 clearly it’s broken)

- 2 weeks, 2 days ago

Wait for a while my program is almost completed

- 2 weeks, 2 days ago

The next question would be to find a generator for this sequence (square root being non palindromic)

- 2 weeks, 3 days ago

You are asking for this right?(non palindromic numbers whose squares are palindromic)

 26 676 264 69696 307 94249 836 698896 2285 5221225 2636 6948496 22865 522808225 798644 637832238736 1270869 1615108015161 2012748 4051154511504 2294675 5265533355625

- 2 weeks, 3 days ago

Code for printing the above seq is :

  1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 for n in range(1,10000000): t=n**2 ta=str(t) z=len(ta) za=z//2 a=-1 for A in range(za): if ta[A]==ta[a]: A+=1 a-=1 else: break else: zo=str(n) k=len(zo) zum=k//2 c=-1 for t in range(zum): if zo[t]!=zo[c]: t+=1 c-=1 else: break else: print(zo,ta) 

- 2 weeks, 3 days ago

  1 2 3 4 5 6 7 8 9 10 11 12 i=1 while True: st=str(i**2) li=list(st) if li==li[::-1]: st=str(i) li=list(st) if li==li[::-1]: print(i,"\t",i**2,"palindromic root") else: print(i,"\t",i**2,"non palindromic root") i+=1 

This is what I used

- 2 weeks, 3 days ago

Yeah this one's more efficient and economical, great job!

$\tiny{\text{but my output is more effective :P}}$

- 2 weeks, 3 days ago

I was not asking this actually, I was asking for a generator, which can find such numbers without brute force

- 2 weeks, 3 days ago

An example is the generator for perfect numbers, $2^{p-1}(2^p-1)$ where p and $2^p-1$ are primes

- 2 weeks, 3 days ago

This generator gives all the perfect numbers but a generator doesn’t have to give all the numbers of the sequence intended

- 2 weeks, 3 days ago

Dude I understood what y meant ...I was searching for something useful like this and this one's awesome too.

Edit:check out this prog For reversing the digits of a number

  1 2 3 4 5 6 7 8 9 10 11 import math n=int(input('ent')) z=math.ceil(math.log10(n)) best=0 for t in range(0,z): a=10**(z-t-1) b=math.floor(n/10**t) c=math.floor(b/10) TA=a*(b-(10*c)) best=best+TA print(best) 

- 2 weeks, 3 days ago

Can you give a hint on what the program should be doing, I really don’t want to find out what those nine variables $\tiny\text{should}$ stand for

- 2 weeks, 3 days ago

Edit edit EDIT: I started a new thread and mentioned u twice, go check that out! frmla for rev the digits of a no.

- 2 weeks, 3 days ago

I just wanted to know something, do you have a phobia towards lists, strings, etc?

- 2 weeks, 2 days ago

Yes I'm very scared of lists and tuples, Man! my cs.teacher was so worried during my practicals, that she started having a panick attack...-_- don't mess with me kiddo

- 2 weeks, 2 days ago

Anyway this what I did for the even palindrome

  1 2 3 4 5 6 7 8 9 10 i=1 while True: if i%10==0: i+=1 li=list(str(i)) li.extend(li[::-1]) palsq=int("".join(li)) if int(palsq**0.5)==palsq**0.5: print(palsq**0.5,palsq) i+=1 

- 2 weeks, 2 days ago

Even better than mine(which is still in progress), great work!

- 2 weeks, 2 days ago

The odd boy, comparatively much slower due to adding in that middle digit

  1 2 3 4 5 6 7 8 9 10 11 12 i=1 while True: li=list(str(i)) for z in range(0,10): ti=li[::] ti.extend(li[::-1]) ti.insert(int(len(ti)/2),str(z)) palsq=int("".join(ti)) if int(palsq**0.5)==palsq**0.5: if not list(str(int(palsq**0.5)))==list(str(int(palsq**0.5)))[::-1]: print(palsq**0.5,palsq) i+=1 

- 2 weeks, 2 days ago

It's AwEsOmE !! just edit the else part a bit to make it more presentable

- 2 weeks, 2 days ago

It broke before it found new ones, have to remake square root function if we need to find more

- 2 weeks, 2 days ago

You're the kinda person who asks a ques, manages to find the ans and then flex it on the person whom u asked right ??

- 2 weeks, 2 days ago

Nope genuinely saw the problem and have/had no solution to it (I don’t want to make a square root function, it’s gonna be a pain)

- 2 weeks, 2 days ago

My exams got cancelled yesterday, so I can do that (maybe)

- 2 weeks, 2 days ago

Mine too sadly, now I have total uncertainty on how they will grade me

- 2 weeks, 2 days ago

Same ,btw we do have a sqrt func in math lib of python...will that work?

- 2 weeks, 2 days ago

This is the frequency of the middle digit, includes palindromic root too, I thought some numbers might not be possible but everything is :(

 1 1 2 3 3 2 4 9 5 5 6 8 7 6 8 9 9 2

- 2 weeks, 2 days ago

Oh....btw may I know these "seeming not possible" nos that are possible?

- 2 weeks, 2 days ago

Maybe you wanted to actually divide the 2.303 rather than multiply right

- 2 weeks, 3 days ago

I suggest replacing the 2.303 with math.log(10) or changing the base altogether by doing math.log(n,10)

- 2 weeks, 3 days ago

I wanted to change the ln to $\log_{10}$..okay I'll update it

- 2 weeks, 3 days ago

Why have you added one to z to subtract one from it everywhere required

- 2 weeks, 3 days ago

Oh yeah I coul d have just written z :P guess I got too involved in the research

- 2 weeks, 3 days ago

No no it was correct, actually z was storing the no.of digits of the reqd no.

- 2 weeks, 2 days ago

The function sum should used on an iterable like a list or a set

- 2 weeks, 3 days ago

Okay cool, thanks for clarifying that one lol

- 2 weeks, 3 days ago

New thread, I found out that square root function is still enough accurate though, if it makes a mistake then it’s easy to spot because it will be either one number below or above, and by comparing the root and square’s last digit, you can find whether it’s right or not

- 2 weeks, 2 days ago

That math sqrt one right? That's grt!

- 2 weeks, 2 days ago