Project

General

Profile

Actions

Feature #11578

closed

Add a method to check if a number is probably prime or composite (Patch included)

Added by chaitanyav (NagaChaitanya Vellanki) about 9 years ago. Updated about 9 years ago.

Status:
Rejected
Target version:
-
[ruby-core:<unknown>]

Description

Added a method to check if a given n is probably prime or composite using Miller- Rabin Test. This method is faster that the sieve method to check for an arbitrary n. Please review my pull request.

https://github.com/ruby/ruby/pull/1051


Files

0001-Add-Prime.probably_prime.patch (4.46 KB) 0001-Add-Prime.probably_prime.patch chaitanyav (NagaChaitanya Vellanki), 10/10/2015 02:33 AM

Updated by chaitanyav (NagaChaitanya Vellanki) about 9 years ago

  • Subject changed from add a method to check if a number is probably prime or composite to Add a method to check if a number is probably prime or composite (Patch included)
  • Assignee set to chaitanyav (NagaChaitanya Vellanki)

Updated by chaitanyav (NagaChaitanya Vellanki) about 9 years ago

  • Assignee changed from chaitanyav (NagaChaitanya Vellanki) to matz (Yukihiro Matsumoto)

Updated by naruse (Yui NARUSE) about 9 years ago

  • Status changed from Open to Rejected

Use OpenSSL::BN.

Updated by chaitanyav (NagaChaitanya Vellanki) about 9 years ago

Yui NARUSE wrote:

Use OpenSSL::BN.

Rehearsal ---------------------------------------------------------------
Probably prime 11.990000 0.060000 12.050000 ( 12.054223)
OpenSSL::BN.prime_fasttest? 0.020000 0.000000 0.020000 ( 0.024519)
----------------------------------------------------- total: 12.070000sec

                              user     system      total        real

Probably prime 12.090000 0.050000 12.140000 ( 12.147566)
OpenSSL::BN.prime_fasttest? 0.020000 0.000000 0.020000 ( 0.021217)

Thanks for closing.

Updated by chaitanyav (NagaChaitanya Vellanki) about 9 years ago

NagaChaitanya Vellanki wrote:

Yui NARUSE wrote:

Use OpenSSL::BN.

Rehearsal ---------------------------------------------------------------
Probably prime 11.990000 0.060000 12.050000 ( 12.054223)
OpenSSL::BN.prime_fasttest? 0.020000 0.000000 0.020000 ( 0.024519)
----------------------------------------------------- total: 12.070000sec

user system total real
Probably prime 12.090000 0.050000 12.140000 ( 12.147566)
OpenSSL::BN.prime_fasttest? 0.020000 0.000000 0.020000 ( 0.021217)

Thanks for closing.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0