Hello! This is Kenneth J Han!
In this post, we are going to look at function (or method).
007. Function Method
Problem
Create a function (or a method) called Factorial.
The Factorial has one integer parameter "num" and returns factorial value of "num".
Calculate the value of 3 factorial, 4 factorial and 5 factorial.
Pseudocode
Factorial(num)
result ← 1
WHILE num > 0
result ← result * num
num ← num - 1
RETURN result
result3 ← Factorial(3)
result4 ← Factorial(4)
result5 ← Factorial(5)
PRINT result3, result4, result5
Answer
6 24 120
Your source code is on ready to serve!
Python source code answer on Github
Java source code answer on Github
See you on next post!