User:Vidyadhanam/sandbox

From Wikipedia, the free encyclopedia

Ankit's Primality Test: A New deterministic Primality Test Algorithm[edit]

This article introduces Ankit's Primality Test, a novel algorithm for determining whether a number is prime. Ankit's Primality Test is a deterministic algorithm. The algorithm, presented by Ankit Abhishek on his official YouTube channel, is claimed to be 5-6 times faster than the traditional trial division method. This article analyzes the algorithm, its theoretical underpinnings, and its potential impact on primality testing. Ankit has also claimed on his YouTube channel that he is not able to publish it in journals because he can not bear the costs.

Primality testing, the process of determining whether a number is prime (divisible only by 1 and itself), is a fundamental problem in number theory with applications in cryptography, coding theory, and other areas. While efficient algorithms like the Miller-Rabin test exist, the search for even faster and more deterministic methods continues. Ankit's Primality Test emerges as a promising contender in this pursuit.

Ankit Abhishek
NationalityIndian

Ankit's Primality Test relies on a set of numbers called Ankit numbers. These are odd numbers greater than or equal to 9 with a digit other than 5 in the unit's place and leave non-zero remainders when divided by 3 and 7 including 3 and 7 itself to Ankit Number.


formula for checking Ankit Number for odd number a which is grater than equal to 9 and it has digit other than 5 in it's unit place is:

eg. 15 can not be considered for checking for Ankit Number because it has 5 in it's unit place.

(a mod 3 ≠ 0) and (a mod 7 ≠ 0)

where, a is the odd number grater than equal to 9 and it has digit other than 5 in it's unit place.

3 and 7 itself are Ankit Numbers.

eg. Ankit Numbers up to 40 are:

3,7,11,13,17,19,23,29,31,37


Ankit Number have following properties:

  • Around 50 percent Ankit Numbers are prime numbers
  • and around 50 percent Ankit Numbers are non prime odd numbers whose ones place is not held by 5 (pseudoprimes)

The algorithm's implementation is relatively straightforward. Here's the code for key steps:

Checking for Ankit Numbers:

JavaScript code

For a number n:

let n = 11; // Put the number here to check for Ankit number.

if(n >= 9){
    let nString = n+"";
    if(nString[nString.length - 1] != 5){
        if(n % 2 != 0){
            if(n % 3 != 0 && n % 7 != 0){
                console.log(n + " is an Ankit number.");
            }else{
                console.log(n + " is not an Ankit number.");
            }
        }else{
            console.log(n+ " is not an Ankit number.");
        }
    }else{
       console.log(n+ " is not an Ankit number.");
    }
}else{
    let msg = n+ " is not an Ankit number.";
    (n == 3 || n == 7) ? msg = n +" is an Ankit number." : null;
    console.log(msg);
}

Generating Ankit Numbers up to a Certain Range: JavaScript code

let range = 12; // Put the number here for max generation range.

for (let i = 0; i <= range; i++) {

  if(isAnkitNumber(i)){
    console.log(i);
  }
    
}

function isAnkitNumber(n){

    let isTrue = false;

    if(n >= 9){
        let nString = n+"";
        if(nString[nString.length - 1] != 5){
            if(n % 2 != 0){
                if(n % 3 != 0 && n % 7 != 0){
                    isTrue = true;
                }
            }
        }
    }else{
        (n == 3 || n == 7) ? isTrue = true : null;
    }

    return isTrue;

}


Ankit's Primality Test To test if a number p is prime, the algorithm finds all Ankit numbers a up to the square root of p and checks if p modulo each Ankit number is not equal to 0. If this condition holds for all Ankit numbers, then with 100 percent accuracy p is prime.

p is prime if:

p mod a ≠ 0

here, p is the odd number greater than equal to whose ones place is not held by 5.

and a is all the Ankit Numbers up to √p.

that means p modulo each Ankit number(a)should not equal to 0

JavaScript code for Ankit's Primality Test

let p = 881; // Put the number here to test for primality.


var ankitNumbers = [];
if(p >= 9){

let range = Math.floor(Math.sqrt(p));

for (let i = 0; i <= range; i++) {

  if(isAnkitNumber(i)){
    ankitNumbers.push(i);
  }

  if(i == range){
      console.log(checkPrime(ankitNumbers) ? p + " is a Prime number!" : p + " is not a Prime number.");
  }
    
}

}else{

    (p == 2 || p == 3 || p == 7) ? console.log(p + " is a Prime number!") : console.log(p + " is not a Prime number.");

}

function isAnkitNumber(n){

    let isTrue = false;

    if(n >= 9){
        let nString = n+"";
        if(nString[nString.length - 1] != 5){
            if(n % 2 != 0){
                if(n % 3 != 0 && n % 7 != 0){
                    isTrue = true;
                }
            }
        }
    }else{
        (n == 3 || n == 7) ? isTrue = true : null;
    }

    return isTrue;

}


function checkPrime(){

    isPrime = true;

    for (let i = 0; i < ankitNumbers.length; i++) {
        const a = ankitNumbers[i];
        if(isAnkitNumber(p)){
            if(p % a == 0){
                isPrime = false;
            }
            if(i == ankitNumbers.length - 1){
                return isPrime;
            }
        }else{
            isPrime = false;
            return isPrime;
        }
    }

}

if you will use static list of pre-generated Ankit Numbers then execution of Ankit's Primality Test will be faster.

The key advantage of Ankit's Primality Test lies in its reduced number of divisions compared to trial division. By utilizing the properties of Ankit numbers, the algorithm avoids unnecessary checks on composite numbers, leading to faster execution. However, the algorithm's complexity is not yet fully characterized. While it is not a provably polynomial-time algorithm, empirical evidence suggests its runtime is significantly lower than trial division for large numbers.


If further research validates the efficiency of Ankit's Primality Test, it could have significant implications for various fields. Faster primality testing can lead to improved performance in cryptography, where prime numbers play a crucial role in secure communication protocols. Additionally, the algorithm's potential for parallelization could further accelerate primality testing for large-scale computations.


Ankit's Primality Test presents a promising new approach to primality testing with the potential to outperform existing methods. While further theoretical analysis and empirical testing are necessary to fully assess its capabilities, the initial findings are encouraging. Continued research on this algorithm and its optimization could pave the way for significant advancements in primality testing and its related applications.


Several avenues remain open for future exploration regarding Ankit's Primality Test. One direction involves a rigorous complexity analysis to determine the algorithm's theoretical runtime. Additionally, investigating the distribution of Ankit numbers and their impact on the algorithm's performance for different types of numbers is crucial. Furthermore, exploring parallelization techniques and hardware optimization strategies could further enhance the algorithm's speed and efficiency.


Category:Prime numbers Category:Cryptographic algorithms Category:Primality tests Category:Algorithms Category:Number theory Category:Number theoretic algorithms