Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Code Snippets / simple math functions

Author
Message
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 24th Mar 2006 12:56 Edited at: 15th May 2006 07:56
I was watching Discovery channel about ancient Indian math, and here's my learned results. Didn't realize how much India came up with until watching that show.

Two functions, for calculating permutations and factorials. (hmm, guess I didn't really need to use the -1 step)




Alien 001
19
Years of Service
User Offline
Joined: 4th Jul 2005
Location: Gateshead UK
Posted: 30th Mar 2006 16:51
Nince little snippet. But it can not cal !20,000,000 . I have made an program that cal factorial in VB. it takes about 6,min. Mind it does this buy short hand.
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 15th May 2006 07:58
I changed it to use double integer, 8 bytes i think. Even at that size, its quite limited to small numbers as input.


3Nigma
18
Years of Service
User Offline
Joined: 23rd Apr 2006
Location: RoManiA
Posted: 15th May 2006 18:12 Edited at: 16th May 2006 20:01
man...i'm relative new to darkbasic but i think DB suports recursive calling...so here is a recursive function for factorial....it'smuch more quicker!



cheers

Knowledge belongs to the world...but not this time
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 16th May 2006 09:02
I'm not sure why you think recursion would be faster. I didn't think it would be, so I ran a test. The recursion proves slower.




3Nigma
18
Years of Service
User Offline
Joined: 23rd Apr 2006
Location: RoManiA
Posted: 16th May 2006 20:01
oh well...back to the drawing board... Anyway...I usually don't use recursive in my programs but i thought this would be an alternative to your factorial function!Guess not...

Knowledge belongs to the world...but not this time

Login to post a reply

Server time is: 2024-11-23 03:25:10
Your offset time is: 2024-11-23 03:25:10