#
# This program computes the factorial of numbers greater than 20.
# Ruby's Integer type automatically expands to arbitrary size,
# making it ideal for very large factorials.
#
#
# Compute factorial using Ruby's built‑in big‑integer support.
# The algorithm multiplies numbers from 2 to n.
#
def factorial_big(n)
result = 1
(2..n).each do |i|
result *= i
end
result
end
#
# Main entry point: read input, compute factorial, print result.
#
print "Enter a number greater than 20: "
n = Integer(gets.chomp)
result = factorial_big(n)
puts "\nFactorial of #{n} is:\n\n"
puts result
#
# run:
#
# Enter a number greater than 20: 25
#
# Factorial of 25 is:
#
# 15511210043330985984000000
#