Class: Integer

Inherits:
Object show all
Defined in:
lib/crystel.rb

Instance Method Summary collapse

Instance Method Details

#additorialObject



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

#adtObject



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

#factorialObject



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

#fctObject



62
63
64
# File 'lib/crystel.rb', line 62

def fct
  self.factorial
end

#radtObject



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

#rfctObject



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

#xxObject



84
85
86
# File 'lib/crystel.rb', line 84

def xx
  puts self**self
end