Class: Fixnum
- Inherits:
-
Object
- Object
- Fixnum
- Defined in:
- lib/mani_zanec_math/fixnum/fibo.rb,
lib/mani_zanec_math/fixnum/prime.rb
Instance Method Summary collapse
Instance Method Details
#fibo? ⇒ Boolean
2 3 4 5 6 7 8 9 10 |
# File 'lib/mani_zanec_math/fixnum/fibo.rb', line 2 def fibo? arr = [0,1] while self > arr.last x, y = arr.pop(2) arr.push(x, y, x + y) end return true if self == arr.last return false end |
#prime? ⇒ Boolean
2 3 4 5 6 7 8 9 |
# File 'lib/mani_zanec_math/fixnum/prime.rb', line 2 def prime? return true if self == 1 2.upto(self) do |num| if self % num == 0 return self == num end end end |