Re: Number-Theory :: All-Digit Perfect Squares

*To*: mathgroup at smc.vnet.net*Subject*: [mg64286] Re: Number-Theory :: All-Digit Perfect Squares*From*: Bill Rowe <readnewsciv at earthlink.net>*Date*: Thu, 9 Feb 2006 02:45:06 -0500 (EST)*Sender*: owner-wri-mathgroup at wolfram.com

On 2/8/06 at 3:54 AM, bdsatish at gmail.com (bd satish) wrote: >I set out to write a code that generates nine-digit >perfect square numbers , with each of the digits 1,2,3,...9 >occuring only once in a given number. An example is 139854276 = >11826^2 . Obviuously , all such numbers must lie in the interval >[123456789 , 987654321] . Since 11111^2 < 123456789 and 31427^2 > >987654321 , all the square numbers must have their square-roots in >the interval (11111,31427) . <code snipped> The square roots of the desired numbers can be generated in one line as: In[8]:= s = Cases[Range[11111, 31427], _?(Length@Complement[IntegerDigits[#^2],{0}] == 9&)] Out[8]= {11826, 12363, 12543, 14676, 15681, 15963, 18072, 19023, 19377, 19569, 19629, 20316, 22887, 23019, 23178, 23439, 24237, 24276, 24441, 24807, 25059, 25572, 25941, 26409, 26733, 27129, 27273, 29034, 29106, 30384} and the desired numbers can be obtained by simply squaring s Or if you prefer having the 9 digit numbers in one line rather than the square roots simply change where the squaring takes place, i.e., Cases[Range[11111, 31427]^2, _?(Length@Complement[IntegerDigits[#],{0}] == 9&)] -- To reply via email subtract one hundred and four