On Oct 16, 5:37 am, ankur aggarwal <ankur.mast....@gmail.com> wrote:
> yeh..
> no shortcut..
>
> On Thu, Oct 15, 2009 at 9:44 PM, harit agarwal <agarwalha...@gmail.com>wrote:
>
>
>
> > no use of all these logics.....u have 2 calculate whole value of 100! for
> > summation...
> > use link list to store final value...after ever product...- Hide quoted 
> > text -

Well, you can use a language that makes it easy:

CL-USER> (defun fact (x) (if (zerop x) 1 (* x (fact (1- x)))))
CL-USER> (fact 5)
120
CL-USER> (fact 100)
93326215443944152681699238856266700490715968264381621468592963895217599993229915608941463976156518286253697920827223758251185210916864000000000000000000000000
CL-USER> (defun sumdigits (x) (if (zerop x) 0 (+ (mod x 10) (sumdigits
(truncate x 10)))))
CL-USER> (sumdigits 1239)
15
CL-USER> (sumdigits (fact 100))
648

--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to