Task of Challenge #06/54
Calculate 9! a for-loop
.
Solution
Explanation
To create the factorial of 9 we make almost the same as in challenge #05 but with a different loop body code block.
Last time we used this statement to gather the accumulated sum sum+=i
. Knowing a bit about mathematics means you are aware of the fact that a factorial is nothing more than a chained multiplication.
So 9!
is nothing more than 9*8*7*6*5*4*3*2*1
. Together with the knowledge about for-loops
we can draw advantages out of this by using the running index of i
to create a factorial. To get our desired result, we iterate exact 9 times!
Follow me on Instagram and don’t miss the latest Challenge!
https://www.instagram.com/arnold.code/
Gather more Knowledge about JavaScript?
Here are two pre-picked and high quality Medium articles for you.
Quick 3-Minute Guide for the Monday Morning about https://t.co/thEjiQhZR6() @JS_PlainEnglish https://t.co/thEjiQhZR6() https://t.co/Fg4ky3xvn9 #javascript #learning #coding #Frontend #Developer #programmer #Guide #tutorial #Fastlane #QuickHits #easyaccess #learntocode
— ArnoldCode (@ArnoldAbrahamP1) March 29, 2021
Document object model Free DOM Guide for everyone!https://t.co/yjO6OMy3uy#HTML #html5 #htmlcss #htmlcode #htmlemail #htmlcoding #medium #tutorial #Tutorials #WritingCommunity #webdesign #website #web #webdesigner #webdevelopment #WebDeveloper #code #coder #CodersTeach #coder
— ArnoldCode (@ArnoldAbrahamP1) December 23, 2020