Ask coding questions

← Back to all posts
Function for 1! + 2! + ... + N!. Is working fine, but is printing 1!, 1! + 2!, 1! + 2! + ... + N!
BhaiBhai

Is working fine, but is printing 1!, 1! + 2!, 1! + 2! + ... + N!

for example, when N = 5 it prints "1, 3, 9, 33, 153" instead of just 153

Voters
BhaiBhai
Comments
hotnewtop
Spacecraft

If you move print(Sum) out of the FOR loop, then it will only print the final result instead of every iteration.