Socket
Book a DemoInstallSign in
Socket

mrd_prime

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mrd_prime

0.1.0
bundlerRubygems
Version published
Maintainers
1
Created
Source

MrdPrime

Miller-Rabin Prime Number Determination.

A small number(~2^81) makes a definitive decision. A large number will fallback to OpenSSL::BN::prime?.

About the amount of calculation

In order to reduce the amount of calculation, a decision is made using the minimum amount of calculation. For example, just testing on 2 will determine up to 2047. Testing on 2 and 3, gives a decision up to 1373653.

https://en.wikipedia.org/wiki/Miller%E2%80%93Rabin_primality_test#Testing_against_small_sets_of_bases
"if n < 3,317,044,064,679,887,385,961,981,
it is enough to test a = 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, and 41.
and the result will be deterministic."

Installation

Add this line to your application's Gemfile:

gem 'mrd_prime'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install mrd_prime

Usage

require 'mrd_prime'

small_number = (2**79 + 23)

puts( small_number.mrd_prime? )  #=> true

If you want to use the name prime?, you can alias it.

class Integer
	alias_method :prime?, :mrd_prime?
end

puts( (2**79 + 23).prime? )  #=> true

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/Matsuyanagi/mrd_prime .

FAQs

Package last updated on 07 Aug 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.