@Dave great one.

On Sun, Feb 27, 2011 at 3:33 AM, Dave <dave_and_da...@juno.com> wrote:
> Another optimization: Since the sum of the digits of n^2 is 45, n^2 is
> divisible by 9. Thus, we need consider only n values that are
> divisible by 3. Thus, the outer for-loop can be written
>
> for( n = 31992 ; n < 99381 ; n+=3 )
>
> Dave
>
> On Feb 23, 7:02 pm, Dave <dave_and_da...@juno.com> wrote:
>> Try this:
>>
>>         int i,k,n;
>>         long long j,nsq;
>>         for( n = 31623 ; n < 100000 ; ++n )
>>         {
>>                 nsq = (long long)n * (long long)n;
>>                 j = nsq;
>>                 k = 0;
>>                 for( i = 0 ; i < 10; ++i )
>>                 {
>>                         k |= (1 << (j % 10));
>>                         j /= 10;
>>                 }
>>                 if( k == 01777 )
>>                         printf("%i %lli\n",n,nsq);
>>         }
>>
>> It finds 76 answers in the blink of an eye, the first being 32043^2
>> and the last being 99066^2.
>>
>> Dave
>>
>> On Feb 22, 3:17 pm, bittu <shashank7andr...@gmail.com> wrote:
>>
>>
>>
>> > How to find a number of 10 digits (non repeated digits) which is a
>> > perfect square? perfect square examples: 9 (3x3) 16 (4x4) 25(5x) etc.
>> > Ten digit number example 1,234,567,890
>>
>> > Thanks & Regards
>> > Shashank- Hide quoted text -
>>
>> - Show quoted text -
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Algorithm Geeks" group.
> To post to this group, send email to algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to 
> algogeeks+unsubscr...@googlegroups.com.
> For more options, visit this group at 
> http://groups.google.com/group/algogeeks?hl=en.
>
>



-- 
Thanks & Regards,
Gaurav Gupta
Associate Software Engineer
IBM Software Lab India
Email: gauravgupta[at]in[dot]ibm[dot]com
Ph No. : +91-7676-999-350

"Quality is never an accident. It is always result of intelligent
effort" - John Ruskin

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to