0
Faculty
Is it possible to calculate the faculty (n!) with a for lus?
3 odpowiedzi
+ 2
int num = 5;
int faculty = 1;
for (int i = 1; i <= num; i++){
faculty*=i; //faculty = faculty * i
}
i = 1 --> faculty = 1
i = 2 --> faculty = 2
i = 3 --> faculty = 6
i = 4 --> faculty = 24
i = 5 --> faculty = 120
--> 5! = 120
0
is this in Python?