@dave...plz read the q carefully before answering the q..... nice link anurag...:))
On Sun, Mar 20, 2011 at 11:03 PM, Dave <dave_and_da...@juno.com> wrote: > @Akash: The sum of the numbers from 1 to n is S(n) = n*(n+1)/2. Thus, > the sum of the numbers from a to b is S = S(b) - S(a-1) = ( b*(b+1) - > a*(a-1) ) / 2. > > Dave > > On Mar 20, 9:08 am, Akash Mukherjee <akash...@gmail.com> wrote: > > Majid is a 3rd-grade elementary student and quite well in mathematics. > Once, > > Majid's teacher asked him to calculate the sum of numbers 1 through n. > > > > Majid quickly answered, and his teacher made him another challenge. He > asked > > Majid to calculate the sum of the digits of numbers 1 through n. > > > > Majid did finally find the solution. Now it is your turn, can you find a > > solution? > > Input > > > > Two space-separated integers 0 <= a <= b <= 109. > > > > Program terminates if a and b are -1. > > Output > > > > The sum of the digits of numbers a through b. > > Example > > > > *Input:* > > 1 10 > > 100 777 > > -1 -1 > > *Output:* > > 46 > > 8655 > > > > ne ideas?? > > -- > 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. > > -- Sanchit Mittal Second Year Undergraduate Computer Engineering Delhi College of Engineering ph- +919582414494 -- 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.