cant u use a string yaar.fruity gethu thaan On Fri, Jul 31, 2009 at 9:57 PM, Vivek S <s.vivek.ra...@gmail.com> wrote:
> N! overflows... > Try to write a program to find the value of 30! > You don't have a variable that is large enough to store such a big > number... > > 2009/7/31 sharad kumar <aryansmit3...@gmail.com> > >> check this out >> >> Let x and y be the missing number, >> >> Now equation 1 is : x + y = [n(n+1)/2] - S >> equation 2 is: x * y = N! /P >> solve both we get elements >> >> On Fri, Jul 31, 2009 at 8:27 PM, Devi G <devs...@gmail.com> wrote: >> >>> The logic is actually simple. Tot if we mark in some way an element when >>> it's scanned, we can find the missing numbers in the second scannin. >>> >>> 3,5,1,2,9,10,8,6 >>> >>> When for loop sees '3' it knows elt 3 is there. So multiplies the number >>> at 3rd position by some arbitrary number. (* I've taken the arbitrary >>> number to be n here but CORRECT ONE IS n+3 cos n will fail in some cases >>> *) >>> >>> so, when it sees '5' multiplies the number at 5th position by n+3. >>> It skips when the numbr is greater than n. >>> >>> n+3 = 11 here. >>> >>> So,after first loop, >>> 33, 55, 11, 2 , 99, 110, 8, 66. >>> >>> So now, in the second scan, the indices of all elts that are divisible by >>> n+3 are present in the array. >>> elts at 4th and 7th positions are not divisible. hence missing numbers >>> are 4 and 7. >>> >>> >>> >>> >>> >> >> >> > > > -- > "Reduce, Reuse and Recycle" > Regards, > Vivek.S > > > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---