atropinetears / num-primes Goto Github PK
View Code? Open in Web Editor NEWA Rust Library For Generating Large Composite, Prime, and Safe Prime Numbers
License: Apache License 2.0
A Rust Library For Generating Large Composite, Prime, and Safe Prime Numbers
License: Apache License 2.0
When I wrote a little program to check out how this crate works and I found something strange. Now I am not an expert in prime numbers so I might have done something wrong.
use num_primes::*;
fn main() {
let numbers = [
Generator::new_prime(512),
Generator::new_prime(32),
Generator::new_prime(16),
17957u32.into(),
5u32.into(),
];
for number in numbers {
if Verification::is_prime(&number) {
println!("{} is a prime number", number);
} else {
println!("{} is not a prime number", number);
}
}
}
And the result I got was:
7143985141390067685062171960235716944255257884955901307961617824283167357210788588888340513160296160835326595412561271828611378926148900988701377840767267 is a prime number
2161366811 is a prime number
49331 is a prime number
17957 is not a prime number
5 is not a prime number
I expected both 17957 and 5 to be prime numbers. So I tried to generate a 8 bit prime number but then the program hang. I then tried to find the limit of the minimum number of bits for which a prime number could be generated and found that Generator::new_prime(15)
worked fine but Generator::new_prime(14)
made the program hang (probably stuck in an infinite loop some where).
Hey!
so the prime generator returns BigUint from a private module.
This breaks incompatibility with existing code that uses BigUint.
example of an error:
for
let d = e.invmod(&et);
we get:
expected struct num_bigint::BigUint, found struct num_bigint::biguint::BigUint
Why not return !is_prime
here, when would third branch happens?
Lines 194 to 206 in 5a75765
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.