Relative Content

Tag Archive for runtimeracketfactorial

Why is factorial code scaling strangely with larger integers?

I wrote a Racket program to calculate factorials and ran tests to see how the runtime scaled with different values of n for n!. I was surprised to see that sometimes when scaling n, it caused little increases in the runtime but other times the difference was massive. For instance, increasing n from 10 to 100 increased the runtime by about 8x; scaling n from 1000 to 10000 increase runtime by 380x and scaling n from 10000 to 100000 increased runtime by about 42x.