ImtiazGermain

Crates.ioImtiazGermain
lib.rsImtiazGermain
version0.1.2
sourcesrc
created_at2023-04-11 19:59:33.275408
updated_at2023-04-11 20:04:32.573502
descriptionA Rust library that checks if a number is a Germain and Imtiaz-Germain prime or not
homepage
repositoryhttps://github.com/AitSad/ImtiazGermain
max_upload_size
id836292
size3,990,686
Aitzaz Imtiaz (AitzazImtiaz)

documentation

README

ImtiazGermain

ImtiazGermain is a library intended for number theory, implementing an edited version of Germain primes, which got published in the book A Young Mathematician. Here is a algorithm for ImtiazGermain primes:

Input number n --> Calculate p = (n - 1) / 2 --> Check if n, p, and 2p + 1 are prime ------------------> 
|                                                  |                                                    |
|                                                  No                                                   |
|                                                  |                                                    |
|                                                  V                                                    |
Output "n is not an Imtiaz Germain prime"     <----- Stop                                               |
|                                                                                                       |
Yes                                                                                                     |
|                                                                                                       |
V                                                                                                       |
Calculate m = 2p + 1 --> Check if m is composite --> Calculate q = 2m + 1 --> Check if q is prime -No-->|
|                                                  |                              |                     
|                                                  No                             Yes                   
|                                                  |                              |                     
|                                                  V                              V                     
Output "n is not an Imtiaz Germain prime"     <----- Stop        Output "n is an Imtiaz Germain prime"  

Features

  • Germain Primes detection

  • Imtiaz-Germain primes detection

Installation

To use ImtiazGermain in your Rust project, add the following to your Cargo.toml file:

[dependencies]
ImtiazGermain = "0.1.1"

Alternatively, you can go on python as:

pip install imtiazgermain

Usage

To use ImtiazGermain in your Rust code, import the necessary modules:

use ImtiazGermain::primecheck::{isgermainprime, isimtiazgermainprime};

Then, call the desired encryption or utility function. For example, to encrypt a message using the Caesar cipher:

use std::io;
use ImtiazGermain::primecheck::{isgermainprime, isimtiazgermainprime};

fn main() {
    println!("Enter a number:");
    let mut input = String::new();
    io::stdin().read_line(&mut input).unwrap();
    let n = input.trim().parse::<u64>().unwrap();

    if primecheck::isimtiazgermainprime(n) {
        println!("{} is an Imtiaz Germain prime", n);
    } else {
        println!("{} is not an Imtiaz Germain prime", n);
    }
}

You can use python as follows:

import ImtiazGermain.primecheck as pm

pc = pm.primecheck()
print(pc.isgermainprime(2))    # True
print(pc.isimtiazgermainprime(3))    # True
print(pc.isgermainprime(5)) #True
print(pc.isgermainprime(7))    # True
Commit count: 39

cargo fmt