Skip to content

Instantly share code, notes, and snippets.

@code
Created November 3, 2008 17:38
Show Gist options
  • Save code/21925 to your computer and use it in GitHub Desktop.
Save code/21925 to your computer and use it in GitHub Desktop.
class Fixnum
def even?
num = self
stack = [1]
while(stack.last < num)
stack.push(stack.last*2)
end
while(num > 1)
val = stack.pop
num -= val if val <= num
end
num == 0
end
def odd?
!even?
end
end
puts 1000.even?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment