module AtCoder::Prime

Overview

Implements Ruby's Prime library.

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

Included Modules

Extended Modules

Defined in:

prime.cr

Instance Method Summary

Instance Method Detail

def each(&) #
Description copied from module Enumerable(Int64)

Must yield this collection's elements to the block.


[View source]
def 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]

[View source]
def 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]

[View source]
def int_from_prime_division(prime_divisions : Array(Tuple(Int, Int))) #

[View source]
def prime?(value : Int) #

[View source]
def prime_division(value : Int) #

[View source]