The factorial of a number is the product of all the integers from 1 to that number.
For example, the factorial of 5 (denoted as 6!) is
1*2*3*4*5 = 120.
Factorial is not defined for negative numbers and the factorial of zero is one, 0! = 1
Factorial Example with Dart For Loop
void main() {
var num = 5;
var factorial = 1;
for( var i = num ; i >= 1; i-- ) {
factorial *= i ;
}
print(factorial);
}
|
Output
120
What are #method_missing and #send? Why are they useful?
how to create an array with Array.[](*args) in Ruby ?
How to Get Input with Gets in Ruby
Ruby program to print an array
How to Sort Array in Ruby?
How to add/remove elements to Array in Ruby?
Ruby program to check whether the given number is Armstrong
Ruby program to generate random numbers
Ruby program to check whether the given number is prime or not
Ruby program to check whether the given number is palindrome
How to create two dimensional array in ruby?
Ruby program to Calculate the factorial of given number