aboutsummaryrefslogtreecommitdiffstats
path: root/lib/prime.rb
Commit message (Collapse)AuthorAgeFilesLines
* prime.rb: remove alias after timeout teststomar2017-05-201-1/+1
| | | | | | | | * test/test_prime.rb: remove alias after timeout test. * lib/prime.rb: fix typo. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58813 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* lib/prime: Fix primality of some large integers [#13492].marcandre2017-05-201-2/+2
| | | | | | | | | * lib/prime.rb: Use accurate sqrt to insure all factors are tested. Patch by Marcus Stollsteimer. * test/test_prime.rb: Adapt test for timeout git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58809 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * basictest/test.rb: Adjust spaces in class declarationshsbt2016-10-071-2/+2
| | | | | | | | | | | | with inheritance. [fix GH-1227] Patch by @adrfer * lib/irb/*: ditto. * lib/prime.rb: ditto. * lib/shell/builtin-command.rb: ditto. * object.c: ditto. * sample/*.rb: ditto. * test/-ext-/method/test_arity.rb: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56371 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/prime.rb: Optimize prime?marcandre2016-08-101-5/+6
| | | | | | | | Adapted from patch by Jabari Zakiya [#12665] * test/test_prime.rb: Improve test git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55856 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* Add frozen_string_literal: false for all filesnaruse2015-12-161-0/+1
| | | | | | When you change this to true, you may need to add more tests. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53141 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/prime.rb: Add basic argument checking to Prime.prime?marcandre2015-10-201-0/+2
| | | | | | [Bug #11606] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52201 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/prime.rb: Optimize Integer#prime?marcandre2015-10-201-1/+8
| | | | | | Patch by Nick Slocum [Bug #10354] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52200 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/prime.rb: Return sized enumerators.marcandre2015-06-121-2/+6
| | | | | | Patch by Kenichi Kamiya [GH-931] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50857 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/prime.rb: Fix with_object with no block givenmarcandre2015-06-121-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50856 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/prime.rb: Have with_index accept an offset parameter.marcandre2015-06-121-1/+9
| | | | | | Based on patch by T Yamada. [#11007] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50854 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/prime.rb: Simplify and optimize EratosthenesSievemarcandre2015-06-091-3/+2
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50803 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/prime.rb: Simplify and optimize EratosthenesSievemarcandre2015-06-091-3/+4
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50802 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/matrix.rb: Simplify and optimize EratosthenesSievemarcandre2015-06-091-5/+2
| | | | | | based on patch by Ajay Kumar. [Fixes GH-921] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50800 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/matrix.rb: Stylingmarcandre2015-05-221-6/+6
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50605 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/prime.rb: Remove obsolete Prime.newmarcandre2015-05-221-41/+1
| | | | | | patch by Ajay Kumar. [Fixes GH-891] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@50604 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/prime.rb: Remove useless loop and block capture.marcandre2014-12-101-16/+14
| | | | | | See [#10354] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48767 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/cgi/core.rb: remove unused variables.hsbt2014-07-271-1/+1
| | | | | | | | | | | | | | | | * lib/erb.rb: ditto. * lib/mkmf.rb: ditto. * lib/net/http/response.rb: ditto. * lib/optparse/version.rb: ditto. * lib/prime.rb: ditto. * lib/racc/parser.rb: ditto. * lib/rexml/document.rb: ditto. * lib/rexml/dtd/dtd.rb: ditto. * lib/rexml/element.rb: ditto. * lib/rexml/functions.rb: ditto. * lib/rexml/parsers/xpathparser.rb: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46973 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* prime.rb: fix a grammonobu2014-05-241-1/+1
| | | | | | * lib/prime.rb (prime?): [DOC] fix a grammo, a missing article. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46076 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* add information of incompatibility about Prime.prime? [Bug #7395]ayumin2014-05-231-2/+2
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46061 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/prime.rb (Prime#prime?): negative numbers can't be primesayumin2014-05-081-1/+0
| | | | | | | by definition. reported by Ivan Kataitsev. [Bug #7395] * test/test_prime.rb: add test. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@45878 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/prime.rb (Prime::EratosthenesGenerator,yugui2013-07-151-56/+37
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Prime::EratosthenesSieve): New implementation by robertjlooby <robertjlooby AT gmail.com>. * test/test_prime.rb: updated with new method name commit 4b6090ea852d63b26e02796c69b41caa0fa95077 Merge: ceda881 c8f7809 Author: Yuki Sonoda (Yugui) <yugui@yugui.jp> Date: Mon Jul 15 12:50:04 2013 +0900 Merge commit 'c8f780987fbdfbae428977487e1cf793c4c36d3f' Conflicts: lib/prime.rb commit c8f780987fbdfbae428977487e1cf793c4c36d3f Author: robertjlooby <robertjlooby@gmail.com> Date: Thu Jun 27 23:04:45 2013 -0500 updated test/test_prime.rb with new method name commit 996517bdbb3108cd1687d99613b69e539eb1567b Author: robertjlooby <robertjlooby@gmail.com> Date: Thu Jun 27 22:59:39 2013 -0500 new implementation of Prime::EratosthenesGenerator and Prime::EratosthenesSieve git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41982 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/prime.rb: Corrected a few comments. Patch by @Nullset14.charliesome2013-06-301-18/+18
| | | | | | Fixes GH-346. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41714 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/irb.rb, lib/prime.rb: Typos in overviewzzak2013-01-131-1/+1
| | | | | | | Patch by Ershad K [Github Fixes #234] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38798 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/prime.rb: Indent examples enough to appear as code sections.drbrain2011-06-011-18/+32
| | | | | | | Note that Prime is Enumerable. [#4762] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31880 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib: revert r31635-r31638 and untabify with expand(1).nobu2011-05-191-334/+334
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31641 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib: Convert tabs to spaces for ruby files perdrbrain2011-05-181-337/+337
| | | | | | | | | http://redmine.ruby-lang.org/projects/ruby/wiki/DeveloperHowto#coding-style Patch by Steve Klabnik [Ruby 1.9 - Bug #4730] Patch by Jason Dew [Ruby 1.9 - Feature #4718] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31635 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib: fixed typo. a patch by Sho Hashimoto in [ruby-dev:40716].nobu2010-03-201-1/+1
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26986 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * test/test_prime.rbyugui2009-10-181-19/+43
| | | | | | | | | | | | (TestPrime#test_eratosthenes_works_fine_after_timeout): test for [ruby-dev:39465]. * lib/prime.rb (Prime::EratosthenesSieve): fixed [ruby-dev:39465]. suppressed memory reallocation. constantified some magic numbers. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25388 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/prime.rb (EratosthenesGenerator#initialize): call super.nobu2009-09-131-2/+5
| | | | | | | (TrialDivisionGenerator, Generator23): ditto. [ruby-core:25539] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24884 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/prime.rb (Prime#prime_division): now decomposesyugui2009-07-131-1/+6
| | | | | | | | negative integer into a decomposition with element [-1, 1]. * test/test_prime.rb: test for it. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24091 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/prime.rb: documentation typo fixed. a patch from okkez.matz2009-06-111-2/+2
| | | | | | [ruby-dev:38586] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23665 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * {ext,lib,test}/**/*.rb: removed trailing spaces.nobu2009-03-061-28/+28
| | | | git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22784 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/prime.rb (Prime::prime?): used to return a wrong answer.yugui2009-03-031-0/+2
| | | | | | | | [ruby-core:22646]. * test/test_prime.rb (test_prime?): test case for [ruby-core:22646]. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22741 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/optparse/version.rb: remove variable shadowing to stopmatz2008-12-181-2/+2
| | | | | | | | | | | | | | | | | | | | warning. [ruby-core:20612] * lib/irb/completion.rb, lib/net/imap.rb, lib/prime.rb, lib/rinda/ring.rb, lib/racc/parser.rb, lib/shell/command-processor.rb, lib/yaml/yamlnode.rb: ditto. * lib/racc/parser.rb: remove space before parentheses. * lib/shell/command-processor.rb, lib/shell/process-controller.rb: use parentheses around arguments. * lib/irb/ext/change-ws.rb, lib/rexml/validation/relaxng.rb, lib/yaml/baseemitter.rb: indentation fix. * lib/matrix.rb: small cosmetic change. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20859 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * enumerator.c (enumerator_next): Fix a typo: s/rewinded/rewound/.knu2008-12-101-1/+1
| | | | | | | * lib/prime.rb (Prime::OldCompatibility#each): Ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@20604 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/prime.rb (Prime::OldCompatibility#each): added compatibility toyugui2008-09-041-20/+35
| | | | | | | | Ruby 1.8.7. (Prime#each): added more rdocs. (Prime#each): remembers the last value of the given block. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19135 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* * lib/mathn.rb (Integer): moved into prime.rb.yugui2008-09-031-0/+446
(Prime): ditto. * lib/prime.rb (Integer): moved from mathn.rb. (Integer.each_prime): added. (Integer#prime?): added. (Prime): moved from mathn.rb. Its implmentation was rewritten. see [ruby-dev:35863]. And patched by Keiju ISHITSUKA <keiju@ishitsuka.com>, see [ruby-dev:36128]. (Prime.new): obsolete. (Prime.instance): added. (Prime.each): added. (Prime.int_from_prime_division): added. (Prime.prime_division): added. (Prime.prime?): added. Patch by TOYOFUKU Chikanobu <nobu_toyofuku at nifty.com> in [ruby-dev:36067]. (Prime.cache): removed. (Prime.primes): removed. (Prime.primes_so_far): removed. (Prime#int_from_prime_division): added. (Prime#prime_division): added. (Prime#prime?): added. (Prime#primes): removed. (Prime#primes_so_far): removed. (Prime::PseudoPrmeGenerator): added. (Prime::EratosthenesGenerator): added. (Prime::TrialDivisionGenerator): added. (Prime::Generator23): added. (Prime::TrialDivision): added. Extracted from the previous implementation of Prime by Keiju ISHITSUKA. (Prime::EratosthenesSieve): added. * lib/.document (prime.rb): added * lib/README (prime.rb): added * test/test_prime.rb: added. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19095 b2dd03c8-39d4-4d8f-98ff-823fe69b080e