Prime numbers and factorization library.
Add this line to your application's Gemfile:
And then execute:
Or install it yourself as:
require 'prime' # Prime is the set of all prime numbers, and it is Enumerable. Prime.take(4) #=> [2, 3, 5, 7] Prime.first(4) #=> [2, 3, 5, 7] Prime.each(7).to_a #=> [2, 3, 5, 7] # Determining whether an arbitrary integer is a prime number Prime.prime?(7) #=> true 8.prime? #=> false # Factorization in prime numbers Prime.prime_division(8959) #=> [[17, 2], [31, 1]] Prime.int_from_prime_division([[17, 2], [31, 1]]) #=> 8959 17**2 * 31 #=> 8959
Bug reports and pull requests are welcome on GitHub at https://github.com/ruby/prime.
The gem is available as open source under the terms of the BSD-2-Clause.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.3