function (n)
i = 1
s = 1
while (s <= n)
i = i+1
s = s*i
print "*"
end
Asked
Active
Viewed 124 times
0
1 Answers
0
Assuming all operations are done in constant time, this loop runs in $\Theta(n!^{-1})$ where $!^{-1}$ is the inverse factorial. Intuitively, the program will enter the loop $i$ times, $i$ being the smallest integer so that $i!\geq n$.
Roukah
- 771
- 6
- 13