Thursday, July 1, 2021

Published July 01, 2021 by Anonymous with 1 comment

Count of unique prime numbers formed by deleting digits of given number

import java.io.*;

import java.util.*;

  

public class GFG {

  

    

    

    static boolean checkprime(int n)

    {

        

        if (n == 1) {

            return false;

        }

  

        

        if (n == 2 || n == 3) {

            return true;

        }

  

        

        else if (n % 2 == 0 || n % 3 == 0

                 || n % 6 == 0) {

            return false;

        }

  

        

        for (int i = 6; i * i <= n; i += 6) {

            if (n % (i - 1) == 0

                || n % (i + 1) == 0) {

                return false;

            }

        }

        return true;

    }

  

    

    static HashSet<Integer> Primes

        = new HashSet<>();

  

    

    

    

    

    static void uniquePrimeNums(

        String number, String ans, int index)

    {

        

        if (index == number.length()) {

  

            if (ans.length() != 0)

  

                

                

                if (checkprime(Integer.parseInt(ans))) {

  

                    

                    Primes.add(Integer.parseInt(ans));

                }

  

            return;

        }

  

        

        

        uniquePrimeNums(number,

                        ans + number.charAt(index),

                        index + 1);

  

        

        

        uniquePrimeNums(number, ans, index + 1);

    }

  

    

    public static void main(String[] args)

    {

        

        int number = 132;

  

        

        uniquePrimeNums("" + number, "", 0);

        System.out.println(Primes.size());

    }

}

Adblock test (Why?)


Original page link

Best Cool Tech Gadgets

Top favorite technology gadgets
      edit

1 comment:

  1. Count Of Unique Prime Numbers Formed By Deleting Digits Of Given Number ~ Cnc Software >>>>> Download Now

    >>>>> Download Full

    Count Of Unique Prime Numbers Formed By Deleting Digits Of Given Number ~ Cnc Software >>>>> Download LINK

    >>>>> Download Now

    Count Of Unique Prime Numbers Formed By Deleting Digits Of Given Number ~ Cnc Software >>>>> Download Full

    >>>>> Download LINK VN

    ReplyDelete