+ 1

How this code works?

If I input 0 to this fact function . The answer is 1. But why the for loop is not working for this ? Explain. https://code.sololearn.com/c9LQlk13lc69/?ref=app

13th Apr 2021, 7:44 AM
˜”*°•.˜”*°• Mohan 333 •°*”˜.•°*”˜
˜”*°•.˜”*°• Mohan 333 •°*”˜.•°*”˜ - avatar
3 Réponses
+ 2
When n is 0, it will be range(1, 1). The start and the end is the same and thus the loop doesn't run.
13th Apr 2021, 8:09 AM
你知道規則,我也是
你知道規則,我也是 - avatar
+ 3
I don't understand your question. You don't need the 'if' statement, just a single 'fact = 1', i.e. delete lines 2 and 3. The for loop is working. In the case of n = 0, it runs from 1 to 1.
13th Apr 2021, 8:16 AM
David Ashton
David Ashton - avatar
+ 1
Thanks friends.
13th Apr 2021, 8:20 AM
˜”*°•.˜”*°• Mohan 333 •°*”˜.•°*”˜
˜”*°•.˜”*°• Mohan 333 •°*”˜.•°*”˜ - avatar