Chris White wrote in post #1014256: > Finally for something even more advanced, you can use inject and kill > the need for a recursive call all together: > > class Factorial > def Factorial.fact(n) > (1..n).inject(1, :*) > end > end > > puts Factorial.fact(10) > Great stuff. Now I'm using the ternary operator in my class, with a user prompt as follows, which works well: class Factorial def Factorial.fact(n) (n == 0) ? 1 : n * fact(n-1) end end print "Enter a positive integer: " n = gets.to_i puts "The factorial of #{n} is: #{Factorial.fact(n)}" I will get to the "inject" thing later. What I want to do now is to use exception handling (e.g., in case the user enters the wrong input). Thanks again for the suggestions, that help a lot! -- Posted via http://www.ruby-forum.com/.