Class: Integer
Instance Method Summary collapse
- #additorial ⇒ Object
- #adt ⇒ Object
- #d(number) ⇒ Object
- #factorial ⇒ Object
- #fct ⇒ Object
- #radt ⇒ Object
- #rfct ⇒ Object
- #xx ⇒ Object
Instance Method Details
#additorial ⇒ Object
41 42 43 44 45 46 47 48 49 |
# File 'lib/crystel.rb', line 41 def additorial x = 1 to_return = 0 while x <= self to_return += x x += 1 end to_return end |
#adt ⇒ Object
59 60 61 |
# File 'lib/crystel.rb', line 59 def adt self.additorial end |
#d(number) ⇒ Object
81 82 83 |
# File 'lib/crystel.rb', line 81 def d(number) self.fdiv(number) end |
#factorial ⇒ Object
50 51 52 53 54 55 56 57 58 |
# File 'lib/crystel.rb', line 50 def factorial x = self to_return = 1 while x > 1 to_return *= x x -= 1 end to_return end |
#fct ⇒ Object
62 63 64 |
# File 'lib/crystel.rb', line 62 def fct self.factorial end |
#radt ⇒ Object
65 66 67 68 69 70 71 72 |
# File 'lib/crystel.rb', line 65 def radt x = 1 while x.adt <= self x += 1 end x -= 1 return "#{x} additorial is #{x.adt}. You are #{self-x.adt} off!" end |
#rfct ⇒ Object
73 74 75 76 77 78 79 80 |
# File 'lib/crystel.rb', line 73 def rfct x = 1 while x.fct <= self x += 1 end x -= 1 return "#{x} factorial is #{x.fct}. You are #{self-x.fct} off!" end |
#xx ⇒ Object
84 85 86 |
# File 'lib/crystel.rb', line 84 def xx puts self**self end |