Skip to content

Instantly share code, notes, and snippets.

@pmatsinopoulos
Created June 27, 2023 05:30
Show Gist options
  • Save pmatsinopoulos/da7246906cc060e4cb6923f58404bca8 to your computer and use it in GitHub Desktop.
Save pmatsinopoulos/da7246906cc060e4cb6923f58404bca8 to your computer and use it in GitHub Desktop.
class IntegerToBinary
def initialize(integer)
@integer = integer
end
def binary
return integer.to_s if integer <= 1
"#{IntegerToBinary.new(integer / 2).binary}#{integer % 2}"
end
private
attr_reader :integer
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment