Class: Roebe::Math::Fact
Instance Method Summary collapse
-
#fact(n) ⇒ Object
# === fact ========================================================================= #.
-
#initialize(i) ⇒ Fact
constructor
# === initialize ========================================================================= #.
-
#report_result ⇒ Object
# === report_result ========================================================================= #.
Constructor Details
#initialize(i) ⇒ Fact
#
initialize
#
14 15 16 17 18 |
# File 'lib/roebe/math/fact.rb', line 14 def initialize(i) i = i.to_i fact(i) report_result end |
Instance Method Details
#fact(n) ⇒ Object
#
fact
#
23 24 25 26 27 28 29 30 31 |
# File 'lib/roebe/math/fact.rb', line 23 def fact(n) if n == 0 n = 1 else n = n * fact(n-1) end @n = n return @n end |
#report_result ⇒ Object
#
report_result
#
36 37 38 |
# File 'lib/roebe/math/fact.rb', line 36 def report_result puts @n end |