Factorial · المضروب
Factorial
The factorial n! is the product 1 * 2 * 3 * ... * n. By definition 0! is 1.
Start a result at 1, then multiply it by every integer from 2 up to n in a loop. (The tests keep n at most 10, so the answer fits in an int.)
المضروب
المضروب n! هو الجداء 1 * 2 * 3 * ... * n. حسب التعريف 0! هو 1.
ابدأ النتيجة عند 1، ثم اضربها بكل عدد صحيح من 2 حتى n في حلقة. (الاختبارات تحافظ على n بحد أقصى 10، لذا الإجابة تتسع في int.)
Complete int factorial(int n) to return n! = 1 * 2 * ... * n. Assume 0 <= n <= 10, and factorial(0) is 1. · أكمل int factorial(int n) لإرجاع n! = 1 * 2 * ... * n. افترض أن 0 <= n <= 10، وأن factorial(0) هو 1.
Click Run to see the output here. · اضغط تشغيل لرؤية المخرجات هنا.