if ( n <= 9 )
  return (10+n);

ret = 0;
while (n>9)
{
  found = false;
  for ( i = 9 to 2 )
     if (n%i == 0)
       { ret = ret * 10 + i; n /= i; found = true; }
  if ( !found )
  {
     print( "Not possible");  return;
  }
}

Now sort the digits of ret and return.

However this will work for small numbers. Numbers with 1000 digits will need
different handling.

On 6/10/07, mukesh tiwari <[EMAIL PROTECTED]> wrote:
>
>
> Hi everbody , i am trying to solve this problem
> http://acm.uva.es/p/v105/10527.html  but i am not getting any
> efficient algorithm . One algorithm i applied
> while(n>9)
> for i=2 to 9
>    if(n%i=0)//then i is factor of n and may be a digit in the number
>        store i for further processing
>        n=n/i
>
> now the problem with this algorithm is supose we have input  45
> so answer should be 59 as from defintion
> 59 -> 45
>
> but my algorithm is giving the answer is 335
> as 335 -> 45
> but i have to find out minimum number .Kindly help me . Thnkx in
> advance .
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/algogeeks
-~----------~----~----~----~------~----~------~--~---

Reply via email to