Sunday, January 21, 2018

[Bioinformatics 101] 007. Function Method

Hello! This is Kenneth J Han!

In this post, we are going to look at function (or method).

007. Function Method


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.


    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


6  24  120

If you have difficulties solving problem, visit the links below!
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!

0 개의 λŒ“κΈ€:

Post a Comment