Find the smallest 10-digit number that is a perfect square and contains all the digits 0 to 9.

Find the smallest 10-digit number that is a perfect square and contains all the digits 0 to 9.


The answer is 1026753849.

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

3 solutions

With a program, this problem is solved easily.

Python3
from math import sqrt
# only consider the values from 1,000,000,000 to 10,000,000,000
Start = int(sqrt(1e9)) + 1
End = int(sqrt(1e10))
for n in range(Start, End):
    if len(set(str(n * n))) == 10:
        print(n * n)
        break

shouldn't you employ the information "and it contains all the digits from 0 to 9" in your code? :)

Mehdi K. - 2 years, 1 month ago

It does, the line:

len(set(str(n * n))) == 10

is only true if all digits are present.

Maurice van Peursem - 1 year, 11 months ago

list = Select [ Table [ FromDigits [ p ] , { p , Permutations [ Range [ 0 , 9 ] ] } ] , $#$1 1000000000 & ] ; \text{list}=\text{Select}[\text{Table}[\text{FromDigits}[p],\{p,\text{Permutations}[\text{Range}[0,9]]\}],\text{\$\#\$1}\geq 1000000000\&]; m = Table [ v , { v , list } ] ; m=\text{Table}\left[\sqrt{v},\{v,\text{list}\}\right]; Table [ i 2 , { i , Select [ m , IntegerQ [ $#$1 ] & ] } ] \text{Table}\left[i^2,\{i,\text{Select}[m,\text{IntegerQ}[\text{\$\#\$1}]\&]\}\right] 1026753849 , 1042385796 , 1098524736 , 1237069584 , 1248703569 , 1278563049 , 1285437609 , 1382054976 , 1436789025 , 1503267984 , 1532487609 , 1547320896 , 1643897025 , 1827049536 , 1927385604 , 1937408256 , 2076351489 , 2081549376 , 2170348569 , 2386517904 , 2431870596 , 2435718609 , 2571098436 , 2913408576 , 3015986724 , 3074258916 , 3082914576 , 3089247561 , 3094251876 , 3195867024 , 3285697041 , 3412078569 , 3416987025 , 3428570916 , 3528716409 , 3719048256 , 3791480625 , 3827401956 , 3928657041 , 3964087521 , 3975428601 , 3985270641 , 4307821956 , 4308215769 , 4369871025 , 4392508176 , 4580176329 , 4728350169 , 4730825961 , 4832057169 , 5102673489 , 5273809641 , 5739426081 , 5783146209 , 5803697124 , 5982403716 , 6095237184 , 6154873209 , 6457890321 , 6471398025 , 6597013284 , 6714983025 , 7042398561 , 7165283904 , 7285134609 , 7351862049 , 7362154809 , 7408561329 , 7680594321 , 7854036129 , 7935068241 , 7946831025 , 7984316025 , 8014367529 , 8125940736 , 8127563409 , 8135679204 , 8326197504 , 8391476025 , 8503421796 , 8967143025 , 9054283716 , 9351276804 , 9560732841 , 9614783025 , 9761835204 , 9814072356 1026753849,1042385796,1098524736,1237069584,1248703569,1278563049,1285437609,1382054976,1436789025,1503267984,1532487609, \\ 1547320896,1643897025,1827049536,1927385604,1937408256,2076351489,2081549376,2170348569,2386517904,2431870596,2435718609, \\ 2571098436,2913408576,3015986724,3074258916,3082914576,3089247561,3094251876,3195867024,3285697041,3412078569,3416987025, \\ 3428570916,3528716409,3719048256,3791480625,3827401956,3928657041,3964087521,3975428601,3985270641,4307821956,4308215769, \\ 4369871025,4392508176,4580176329,4728350169,4730825961,4832057169,5102673489,5273809641,5739426081,5783146209,5803697124, \\ 5982403716,6095237184,6154873209,6457890321,6471398025,6597013284,6714983025,7042398561,7165283904,7285134609,7351862049,\\ 7362154809,7408561329,7680594321,7854036129,7935068241,7946831025,7984316025,8014367529,8125940736,8127563409,8135679204,\\ 8326197504,8391476025,8503421796,8967143025,9054283716,9351276804,9560732841,9614783025,9761835204,9814072356

Yvonne Killian
Oct 25, 2018

SQL

Create a table t with a column f containing the integers 0 to 9 and execute the following query

select min (t1.f + 10 * t2.f + 10^2 * t3.f + 10^3 * t4.f + 10^4 * t5.f + 10^5 * t6.f + 10^6 * t7.f + 10^7 * t8.f + 10^8 * t9.f + 10^9 * t10.f)

from t t1, t t2, t t3, t t4, t t5, t t6, t t7, t t8, t t9, t t10

where t1.f not in (t2.f, t3.f, t4.f, t5.f, t6.f, t7.f, t8.f, t9.f, t10.f)

and t2.f not in (t3.f, t4.f, t5.f, t6.f, t7.f, t8.f, t9.f, t10.f)

and t3.f not in (t4.f, t5.f, t6.f, t7.f, t8.f, t9.f, t10.f)

and t4.f not in (t5.f, t6.f, t7.f, t8.f, t9.f, t10.f)

and t5.f not in (t6.f, t7.f, t8.f, t9.f, t10.f)

and t6.f not in (t7.f, t8.f, t9.f, t10.f)

and t7.f not in (t8.f, t9.f, t10.f)

and t8.f not in (t9.f, t10.f)

and t9.f not in (t10.f)

and sqrt (t1.f + 10 * t2.f + 10^2 * t3.f + 10^3 * t4.f + 10^4 * t5.f + 10^5 * t6.f + 10^6 * t7.f + 10^7 * t8.f + 10^8 * t9.f + 10^9 * t10.f)

= round (sqrt (t1.f + 10 * t2.f + 10^2 * t3.f + 10^3 * t4.f + 10^4 * t5.f + 10^5 * t6.f + 10^6 * t7.f + 10^7 * t8.f + 10^8 * t9.f + 10^9 * t10.f) )

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...