- Related Questions & Answers
- Average numbers in array in C Programming
- Add minimum number to an array so that the sum becomes even in C programming
- Arithmetic Mean in C programming
- Concatenate a string given number of times in C++ programming
- Write a program to Delete a Tree in C programming
- Write a function that returns 2 for input 1 and returns 1 for 2 in C programming
- Ways to paint N paintings such that adjacent paintings don’t have same colors in C programming
- Surface Area and Volume of Hexagonal Prism in C programming
- Superperfect Number in C programming
- Super Prime in c programming
- Sums of ASCII values of each word in a sentence in c programming
- Sum triangle from an array in C programming
- C Programming for sum of the series 0.6, 0.06, 0.006, 0.0006, …to n terms
- C Programming for Sum of sequence 2, 22, 222, ………
- Sum of the numbers up to N that are divisible by 2 or 5 in c programming

A super-prime number is A number that occupies prime number position in the sequence of all prime numbers. also known as high order primes, These numbers occupy the position in the sequence of prime number which is equal to Prime number. some super prime numbers are 3,5,11,1 7…

For Example let us Find all super prime numbers less than 13 -

**Input **

13

**Output**

3, 5, 11.

**Explanation** − to find the super prime number less than 13 we will find all prime numbers that are less than 13. So, show all prime numbers less than 13 are 2,3,5,7,11,13. Now, 2 is a prime number, so we will consider the prime number at position to as a super prime number. this means three is a prime number. Similarly, 5 at position 3 , and 11 at position 5 are super prime numbers.

to find all super-prime numbers that are less than a given prime number the will first find all prime numbers that are are less than that number and Store then in an array. from this array will print only those numbers whose position is equal to any of the prime numbers. For example, the prime number at 2nd 3rd 5th 7th 11th 13th…. are considered.

#include<iostream> using namespace std; bool SieveOfEratosthenes(int n, bool isPrime[]) { isPrime[0] = isPrime[1] = false; for (int i=2; i<=n; i++) isPrime[i] = true; for (int p=2; p*p<=n; p++) { if (isPrime[p] == true) { for (int i=p*2; i<=n; i += p) isPrime[i] = false; } } } void superPrimes(int n) { bool isPrime[n+1]; SieveOfEratosthenes(n, isPrime); int primes[n+1], j = 0; for (int p=2; p<=n; p++) if (isPrime[p]) primes[j++] = p; for (int k=0; k<j; k++) if (isPrime[k+1]) cout << primes[k] << " "; } int main() { int n = 343; cout << "Super-Primes less than "<< n << " are :"<<endl; superPrimes(n); return 0; }

Super-Primes less than 343 are : 3 5 11 17 31 41 59 67 83 109 127 157 179 191 211 241 277 283 331

Advertisements