Skip to main content

A Python library for checking if a number is a Imtiaz-Germain and Germain prime or not

Project description

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 desiredfunction. For example, to check if a number is ImtiazGermain or not:

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ImtiazGermain-0.1.2.tar.gz (3.3 kB view details)

Uploaded Source

File details

Details for the file ImtiazGermain-0.1.2.tar.gz.

File metadata

  • Download URL: ImtiazGermain-0.1.2.tar.gz
  • Upload date:
  • Size: 3.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.3

File hashes

Hashes for ImtiazGermain-0.1.2.tar.gz
Algorithm Hash digest
SHA256 86eca0e472f8f00596bab5a8b8c5edff45585c5de86b336683b1a96e30efb005
MD5 8f5f788cef3471b38ccdb06f067790ec
BLAKE2b-256 0c56ebdeadecb2ebba80eaf50dad91d3abcde40e541bb1712c0d014f4f72970b

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page