From: Donnchadh Q=20Donnabh=E1in?= (d_odonnabhain at domain vistech.ie)
Date: Thu 28 Oct 1999 - 15:44:58 IST
Donnchadh O Donnabhain wrote:
>
> "John P . Looney" wrote:
> >
> > Check this out.
> >
> > Into umb-scheme, type:
> >
> > (define (factorial number)(if (= number 0) 1 (* number (factorial (- number 1)))))
> >
> > then:
> >
> > (factorial 5500)
> >
> > How easy would it be to write a tcl, C or C++ function to get the
> > factorial of 5500 ? Scheme rocks!
>
> int factorial(int number){ if (number == 0) return 1; else return
> number*factorial(number-1);}
>
OK that should be:
BigNum factorial(BugNum number){ return (number == 0) ? 1 :
number*factorial(number-1); }
where BigNum is a class which handles big numbers and suitable defined
operators. It's a shame some classes like this aren't defined in the
C++ standard. It's also a shame that operator overloading isn't
available
in Java ...
Donnchadh
-- // Donnchadh O Donnabhain mailto:d_odonnabhain at domain vistech.ie // Vistech Software http://www.vistechsoftware.com // Inchvale House, Douglas West, Cork, Ireland // Ph. +353-21-918166 Fax +353-21-896142
This archive was generated by hypermail 2.1.6 : Thu 06 Feb 2003 - 13:04:48 GMT