Class: Roebe::Math::Fact

Inherits:
Object show all
Defined in:
lib/roebe/math/fact.rb

Instance Method Summary collapse

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_resultObject

#

report_result

#


36
37
38
# File 'lib/roebe/math/fact.rb', line 36

def report_result
  puts @n
end