Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Ruby gem useful in case you need to find out if one number is divisible by another

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 lib
Octocat-spinner-32 test
Octocat-spinner-32 .gitignore
Octocat-spinner-32 Gemfile
Octocat-spinner-32 README.rdoc
Octocat-spinner-32 Rakefile
Octocat-spinner-32 divisible.gemspec
README.rdoc

Divisible

Gem Version

Still using the C way of testing if one number is divisible by another?

Still using this?

x % 13 == 0 && x % 6  == 0 && x % 3 == 0

No need anymore! We present you Divisible. Check if number is divisible by another like a boss!

x.divisible_by? 13, 6, 3

Examples

9.divisible_by? 3  # => true
10.divisible_by? 3  # => false
12.divisible_by? 3  # => true
12.divisible_by? 4  # => true
15.divisible_by? 4 # => false
21.divisible_by? 3,7 # => true
35.divisible_by? 3,5,0 # => false

Same can be done with

Divisible.check(9, 3) # => true
Divisible.check(10, 3) # => false
Divisible.check(12, 3) # => true
Divisible.check(12, 4) # => true
Divisible.check(15, 4) # => false

Install

gem install divisible

Licence

Copyright © 2011 Vlado Cingel, released under the MIT license

Something went wrong with that request. Please try again.