Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

Super-Poulet Number

  • Last Updated : 17 May, 2021

Super-Poulet number is a Poulet number (pseudoprime) to base 2 if each and every divisor D divides 2^{D} - 2    .

Some of the super-poulet numbers are: 
 

341, 1387, 2047, 2701, 3277, 4033…. 
 

 

Check if N is a Super-poulet number

 



Given an integer N, the task is to check N is a Super-Poulet Number.

Examples: 
 

Input: N = 341 
Output: Yes
Input: N = 10 
Output: No 
 

 

Approach: The idea is to generate all the divisors of the number N and for all divisor check D divides 2^{D}-2    . If this condition satisfy for all divisors then the number is super-poulet number.
For Example: 
 

For N = 341,
Divisors of 341 are {1, 11, 31, 341} and, 
\frac{(2^{1} - 2)}{1} = 0
\frac{(2^{11} - 2)}{11} = \frac{2046}{11} = 186
\frac{(2^{31} - 2)}{31} = \frac{2147483646}{31} = 69273666
Similarly, \frac{(2^{341} - 2)}{341}    also gives integer value. 
Therefore, 341 is a super-poulet number. 
 

Below is the implementation of the above approach:
 

Python3




# Python3 implementation to
# check if N is a super Poulet number
import math
 
# Function to find the divisors
def findDivisors(n):
    divisors = []
     
    # Loop to iterate over the
    # square root of the N
    for i in range(1,\
         int(math.sqrt(n) + 1)):
         
        if (n % i == 0) :
 
            # Check if divisors are equal
            if (n / i == i):
                divisors.append(i)
            else:
                divisors.append(i)
                divisors.append(int(n / i))
    return sorted(divisors)
     
# Function to check if N
# is a super Poulet number
def isSuperdNum(n):
    d = findDivisors(n)
     
    # Loop to check that every
    # divisor divides 2^D - 2
    for i in d:
        x = (2**i-2)/i
        if int(x) != x:
            return False
    return True
 
# Driver Code
if __name__ == "__main__":
    n = 341
    if isSuperdNum(n) == True:
        print("Yes")
    else :
        print("No")

C#




// C# implementation to
// check if N is a super Poulet number
using System;
using System.Collections.Generic;
 
class GFG
{
 
  // Function to find the divisors
  static List<int> findDivisors(int n)
  {
    List<int> divisors = new List<int>();
 
    // Loop to iterate over the
    // square root of the N
    for (int i = 1; i < (Math.Sqrt(n) + 1); i++)
    {
      if (n % i == 0)
      {
 
        // Check if divisors are equal
        if (n / i == i)
          divisors.Add(i);
        else
        {
          divisors.Add(i);
          divisors.Add((n / i));
        }
      }
    }
    divisors.Sort();
    return divisors;
  }
 
  // Function to check if N
  // is a super Poulet number
  static bool isSuperdNum(int n)
  {
    List<int> d = findDivisors(n);
 
    // Loop to check that every
    // divisor divides 2^D - 2
    foreach(int i in d)
    {
      double x = (Math.Pow(2, i) - 2) / i;
      if (Math.Truncate(x) != x)
        return false;
    }
    return true;
  }
 
  // Driver Code
  public static void Main(string[] args)
  {
    int n = 341;
    if (isSuperdNum(n) == true)
      Console.Write("Yes");
    else
      Console.Write("No");
  }
}
 
// This code is contributed by chitranayal.

Javascript




<script>
// Javascript implementation to
// check if N is a super Poulet number
 
// Function to find the divisors
function findDivisors(n){
    let divisors = []
     
    // Loop to iterate over the
    // square root of the N
    for(let i = 1; i < Math.floor(Math.sqrt(n) + 1); i++){
         
        if (n % i == 0) {
 
            // Check if divisors are equal
            if (n / i == i){
                divisors.push(i)
            }
            else{
                divisors.push(i)
                divisors.push(Math.floor(n / i))
            }
        }
    }
    return divisors.sort((a, b)=> a - b)
}
     
// Function to check if N
// is a super Poulet number
function isSuperdNum(n){
    let d = findDivisors(n)
     
    // Loop to check that every
    // divisor divides 2^D - 2
    for(let i in d){
        let x = (2**i - 2) / i
 
        if (Math.floor(x) != x){
            return false
        }
    }
    return true
}
// Driver Code
    let n = 341
    if(isSuperdNum(n) == true){
        document.write("Yes")
    }
    else {
        document.write("No")
    }
 
// This code is contributed by _saurabh_jaiswal
 
</script>
Output: 
Yes

 




My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!