Finding Factorial of a Number with JavaScript

Murat Umutlu

0 Comment

Algorithms

First of all we must understand the meaning of factorial:

The factorial function multiply all numbers from our chosen number down to 1.

For instance:

  • 3! = 3 x 2! = 3 x 2 x 1 = 6
  • 5! = 5 x 4! = 5 x 4 x 3 x 2 x 1 = 120
  • 1! = 1
  • 0! = 1

Way of thinking:

  • We need a recursive function to calculate multiply of ordered numbers.
  • We must return 1 when we get 0 and we must stop recursive function.

(Visited 1 times, 1 visits today)

Notice: Undefined variable: single_layout in /home/muumdev/public_html/wp-content/plugins/blogsqode-posts/public/single/template-parts/content-single.php on line 376

Post Comments:

Leave a Reply

Your email address will not be published. Required fields are marked *

Close