TORONTO KIDS COMPUTER CLUB | Tuesday Python Homework 18:30 – 21.10.19
19999
post-template-default,single,single-post,postid-19999,single-format-standard,ajax_fade,page_not_loaded,,qode-theme-ver-7.6.2,wpb-js-composer js-comp-ver-6.10.0,vc_responsive

Tuesday Python Homework 18:30 – 21.10.19

24 Oct Tuesday Python Homework 18:30 – 21.10.19

Question:

The factorial function (symbol: !) says to multiply all whole numbers from our chosen number down to 1.

Examples:

  • 4! = 4 × 3 × 2 × 1 = 24
  • 7! = 7 × 6 × 5 × 4 × 3 × 2 × 1 = 5040
  • 1! = 1

Factorial is not defined for negative numbers, and the factorial of zero is one, 0! = 1

Write a function to find the factorial of a number. The function should take one number as an argument and print the factorial of that number

Sample Input: 
5

Sample Output:
120
Hint:
The factorial of 5 is 1 * 2 * 3 * 4 * 5 = 120 and also use loops inside the function
No Comments

Sorry, the comment form is closed at this time.