@Sankalp: There are 10^10 - 10^9 10-digit numbers. We investigate only
about the sqrt of that many to find out how many both are perfect
squares and have non-repeating digits.

Dave

On Feb 26, 11:31 pm, sankalp srivastava <richi.sankalp1...@gmail.com>
wrote:
> @dave
> But you are going over elements from 35000 to 98000 something anyway
> How is it O(sqrt n) ?
> But I don't think any other approach exists .(One is to use
> permutations (10!-9!) )
>
> On Feb 27, 3:03 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 -- 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.

Reply via email to