U can use recursive function to do it i guess .. On Thu, Dec 29, 2011 at 1:29 AM, Morgan Bauer <[email protected]>wrote:
> There is no way. This is not possible. You must loop, explicitly with a > loop construct or implicitly with recursion. > hth, > ~mhb > > > 2011/12/28 Jérémie Marguerie <[email protected]> > >> Do you really think there is a solution without a loop? :-) >> >> -- >> Jérémie Marguerie >> Le 28 déc. 2011 20:25, "Mayank roy" <[email protected]> a écrit : >> >> want it supposed to be without loops and ---- recursion ---- >>> >>> On Wed, Dec 28, 2011 at 12:34 AM, Nawaid Shamim <[email protected]>wrote: >>> >>>> Oops sorry...you are right...It needs to be incremented in the >>>> function.. I hope that's answers your query. >>>> >>>> Thanks >>>> >>>> Sent from my iPhone >>>> >>>> On Dec 27, 2011, at 19:02, "Jérémie Marguerie" <[email protected]> >>>> wrote: >>>> >>>> You forgot to increment i. >>>> Regards. >>>> >>>> -- >>>> Jérémie Marguerie >>>> Le 27 déc. 2011 19:56, "Nawaid Shamim" <[email protected]> a écrit : >>>> >>>>> Its not the exact code. you can call that function recursively... some >>>>> thing like the code below: >>>>> >>>>> int sum=0; >>>>> int arr[10] = {1......10}; >>>>> int length =10; >>>>> int i=0; >>>>> >>>>> void sum() >>>>> { >>>>> sum+=arr[i]; >>>>> if(i<length) >>>>> sum(); >>>>> return; >>>>> } >>>>> >>>>> now sum variable will hold sum value. This is how functional language >>>>> solve looping problem. >>>>> >>>>> Regards >>>>> >>>>> Nawaid Shamim <http://nawaidshamim.com> >>>>> >>>>> >>>>> On Thu, Dec 22, 2011 at 7:50 PM, Soumyorup Dey <[email protected] >>>>> > wrote: >>>>> >>>>>> *where is d recursion?? :O >>>>>> *$ŎǕмџόЯטּρ δεЎ >>>>>> >>>>>> >>>>>> >>>>>> <http://www.mylivesignature.com> >>>>>> Connect with me on : [image: >>>>>> Facebook]<http://www.facebook.com/soumyorupdey> >>>>>> Chat with me on : [image: Google Talk] soumyorupdey [image: Y! >>>>>> Messenger] [email protected] >>>>>> >>>>>> >>>>>> On Fri, Dec 23, 2011 at 12:03 AM, Nawaid Shamim >>>>>> <[email protected]>wrote: >>>>>> >>>>>>> You may do it with recursion. if u have numbers in an array >>>>>>> >>>>>>> int sum=0; >>>>>>> int sum(int num) >>>>>>> { >>>>>>> sum+=num; >>>>>>> >>>>>>> } >>>>>>> >>>>>>> Alternatively, if u are accepting numbers from user, u can call this >>>>>>> function along with the input statement in which u might need a loop for >>>>>>> input statement at least. >>>>>>> >>>>>>> >>>>>>> Nawaid. >>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>>> Sent from my iPhone >>>>>>> >>>>>>> On Dec 22, 2011, at 17:47, Luke Pebody <[email protected]> >>>>>>> wrote: >>>>>>> >>>>>>> The point was to find the "best optimized" solution. I was >>>>>>> optimizing according to the readability and understandability metrics. >>>>>>> This >>>>>>> is not something I always do. >>>>>>> On 21 Dec 2011 20:07, "Jérémie Marguerie" <[email protected]> >>>>>>> wrote: >>>>>>> >>>>>>>> 2011/12/21 Luke Pebody <[email protected]>: >>>>>>>> > For sheer expressiveness reasons, I would choose something like >>>>>>>> Python's >>>>>>>> > >>>>>>>> >> print sum([int(char) for char in "142857"]) >>>>>>>> > 27 >>>>>>>> >>>>>>>> But the point gere is to find a fast algorithm, you need a low level >>>>>>>> language to do so :) >>>>>>>> >>>>>>>> Thinkinf of that, if we consider the memory block containing the >>>>>>>> string to be 4-bytes aligned, we can process 4 integers in the loop >>>>>>>> and avoid a jump between each byte and only jump each four bytes. >>>>>>>> >>>>>>>> -- >>>>>>>> Jérémie MARGUERIE >>>>>>>> Étudiant à l'EPITA, ing2 >>>>>>>> "Many snake oil algorithms claim unbreakability by claiming to be a >>>>>>>> OTP. >>>>>>>> Pseudo-OTPs give pseudo-security" -- Peter Gutmann >>>>>>>> >>>>>>>> -- >>>>>>>> You received this message because you are subscribed to the Google >>>>>>>> Groups "Google Code Jam" group. >>>>>>>> To post to this group, send email to [email protected]. >>>>>>>> To unsubscribe from this group, send email to >>>>>>>> [email protected]. >>>>>>>> For more options, visit this group at >>>>>>>> http://groups.google.com/group/google-code?hl=en. >>>>>>>> >>>>>>>> -- >>>>>>> You received this message because you are subscribed to the Google >>>>>>> Groups "Google Code Jam" group. >>>>>>> To post to this group, send email to [email protected]. >>>>>>> To unsubscribe from this group, send email to >>>>>>> [email protected]. >>>>>>> For more options, visit this group at >>>>>>> http://groups.google.com/group/google-code?hl=en. >>>>>>> >>>>>>> -- >>>>>>> You received this message because you are subscribed to the Google >>>>>>> Groups "Google Code Jam" group. >>>>>>> To post to this group, send email to [email protected]. >>>>>>> To unsubscribe from this group, send email to >>>>>>> [email protected]. >>>>>>> For more options, visit this group at >>>>>>> http://groups.google.com/group/google-code?hl=en. >>>>>>> >>>>>> >>>>>> -- >>>>>> You received this message because you are subscribed to the Google >>>>>> Groups "Google Code Jam" group. >>>>>> To post to this group, send email to [email protected]. >>>>>> To unsubscribe from this group, send email to >>>>>> [email protected]. >>>>>> For more options, visit this group at >>>>>> http://groups.google.com/group/google-code?hl=en. >>>>>> >>>>> >>>>> -- >>>>> You received this message because you are subscribed to the Google >>>>> Groups "Google Code Jam" group. >>>>> To post to this group, send email to [email protected]. >>>>> To unsubscribe from this group, send email to >>>>> [email protected]. >>>>> For more options, visit this group at >>>>> http://groups.google.com/group/google-code?hl=en. >>>>> >>>> -- >>>> You received this message because you are subscribed to the Google >>>> Groups "Google Code Jam" group. >>>> To post to this group, send email to [email protected]. >>>> To unsubscribe from this group, send email to >>>> [email protected]. >>>> For more options, visit this group at >>>> http://groups.google.com/group/google-code?hl=en. >>>> >>>> -- >>>> You received this message because you are subscribed to the Google >>>> Groups "Google Code Jam" group. >>>> To post to this group, send email to [email protected]. >>>> To unsubscribe from this group, send email to >>>> [email protected]. >>>> For more options, visit this group at >>>> http://groups.google.com/group/google-code?hl=en. >>>> >>> >>> -- >>> You received this message because you are subscribed to the Google >>> Groups "Google Code Jam" group. >>> To post to this group, send email to [email protected]. >>> To unsubscribe from this group, send email to >>> [email protected]. >>> For more options, visit this group at >>> http://groups.google.com/group/google-code?hl=en. >>> >> -- >> You received this message because you are subscribed to the Google Groups >> "Google Code Jam" group. >> To post to this group, send email to [email protected]. >> To unsubscribe from this group, send email to >> [email protected]. >> For more options, visit this group at >> http://groups.google.com/group/google-code?hl=en. >> > > -- > You received this message because you are subscribed to the Google Groups > "Google Code Jam" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/google-code?hl=en. > -- You received this message because you are subscribed to the Google Groups "Google Code Jam" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/google-code?hl=en.
