Ruby program to Calculate the factorial of given number

In this Ruby example to calculate factorial of a number we are using while loop 

puts "Enter the number"

i = 1
fact = 1

while i <= num  #implementation of while loop
    fact *= i
    i += 1

puts "The factorial of #{num} is #{fact}"



Enter the number
The factorial of 5 is 120


Flutter Questions

Android Questions

Python Questions

Java Questions