module

AtCoder::Prime

Inherits Enumerable

Implements Ruby's Prime library.

AtCoder::Prime.first(7) # => [2, 3, 5, 7, 11, 13, 17]

Instance methods

each

Must yield this collection's elements to the block.

Source
each_divisor(value : Int)

Returns an enumerator that iterates through the all positive divisors of the given number. The order is not guaranteed. Not in the original Ruby's Prime library.

AtCoder::Prime.each_divisor(20) do |n|
  puts n
end # => Puts 1, 2, 4, 5, 10, and 20

AtCoder::Prime.each_divisor(10).map { |n| 1.0 / n }.to_a # => [1.0, 0.5, 0.2, 0.1]
Source
each_divisor(value : T, &block : T -> )

Returns an enumerator that iterates through the all positive divisors of the given number. The order is not guaranteed. Not in the original Ruby's Prime library.

AtCoder::Prime.each_divisor(20) do |n|
  puts n
end # => Puts 1, 2, 4, 5, 10, and 20

AtCoder::Prime.each_divisor(10).map { |n| 1.0 / n }.to_a # => [1.0, 0.5, 0.2, 0.1]
Source
int_from_prime_division(prime_divisions : Array(Tuple(Int, Int)))
Source
prime?(value : Int)
Source
prime_division(value : Int)
Source