[algogeeks] Re: Need Algorithm for Persistence number

2007-06-10 Thread Pradeep Muthukrishnan
I think this is not the right approach for you to solve UVA problems...you will have to put in ur time to solve ...thats the only way in which you can improve. I strongly urge the group to stop sending accepted solutions. regards, Pradeep On 6/10/07, Vishal <[EMAIL PROTECTED]> wrote: > > if ( n <

[algogeeks] Re: Need Algorithm for Persistence number

2007-06-10 Thread Vishal
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 sm