Skip to content

Four different implementations of factorial function

Notifications You must be signed in to change notification settings

GalenIvanov/Factorials

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 

Repository files navigation

Factorials

Four different implementations of factorial function in Red

I tried four imlementations of a factorial function:

  • Iterative
  • Optimized iterative, taken from Pharo 9.0 method
  • Recursive
  • Memoized

Here are the results of timing 100000 function calls with argument 12(*):

Iterative   | 0:00:00.445996
Iterative-2 | 0:00:00.541998
Recursive   | 0:00:01.43899
Memoized    | 0:00:00.101999

(*) Red is currently 32-bit and 12 is the greatest integer for which factorial does not lead to number overflow

About

Four different implementations of factorial function

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages