Repository URL to install this package:
|
Version:
2.2.2-1 ▾
|
U:RDoc::NormalClass[iI" Prime:ET@I"Object;To:RDoc::Markup::Document:@parts[o;;[o:RDoc::Markup::Paragraph;[I""The set of all prime numbers.;To:RDoc::Markup::BlankLine S:RDoc::Markup::Heading: leveli: textI"Example;T@o:RDoc::Markup::Verbatim;[I" Prime.each(100) do |prime| ;TI"- p prime #=> 2, 3, 5, 7, 11, ...., 97 ;TI" end ;T:@format0o; ;[I"Prime is Enumerable:;T@o;;[I")Prime.first 5 # => [2, 3, 5, 7, 11] ;T;0S;;i; I"Retrieving the instance;T@o; ;[I"O+Prime+.new is obsolete. Now +Prime+ has the default instance and you can ;TI"#access it as +Prime+.instance.;T@o; ;[I"OFor convenience, each instance method of +Prime+.instance can be accessed ;TI""as a class method of +Prime+.;T@o; ;[I" e.g.;To;;[I"(Prime.instance.prime?(2) #=> true ;TI"(Prime.prime?(2) #=> true ;T;0S;;i; I"Generators;T@o; ;[ I"JA "generator" provides an implementation of enumerating pseudo-prime ;TI"Knumbers and it remembers the position of enumeration and upper bound. ;TI"KFurthermore, it is an external iterator of prime enumeration which is ;TI"#compatible with an Enumerator.;T@o; ;[I"G+Prime+::+PseudoPrimeGenerator+ is the base class for generators. ;TI"0There are few implementations of generator.;T@o:RDoc::Markup::List: @type: LABEL:@items[o:RDoc::Markup::ListItem:@label[I"%+Prime+::+EratosthenesGenerator+;T;[o; ;[I"Uses eratosthenes' sieve.;To;;[I"&+Prime+::+TrialDivisionGenerator+;T;[o; ;[I"$Uses the trial division method.;To;;[I"+Prime+::+Generator23+;T;[o; ;[ I"OGenerates all positive integers which are not divisible by either 2 or 3. ;TI"DThis sequence is very bad as a pseudo-prime sequence. But this ;TI"His faster and uses much less memory than the other generators. So, ;TI"Fit is suitable for factorizing an integer which is not large but ;TI"4has many prime factors. e.g. for Prime#prime? .;T: @fileI"lib/prime.rb;T:0@omit_headings_from_table_of_contents_below0;0;0[ [ [[I"Enumerable;To;;[ ;@V;0I"lib/prime.rb;T[[I" class;T[[:public[[I" instance;F@^[I"new;T@^[:protected[ [:private[ [I" instance;T[[;[ [I" each;F@^[I"int_from_prime_division;F@^[I"prime?;F@^[I"prime_division;F@^[;[ [;[ [[I"OldCompatibility;To;;[ ;@V;0@^[I"Forwardable;To;;[ ;@V;0@^[U:RDoc::Context::Section[i 0o;;[ ;0;0[@V@VcRDoc::TopLevel