answersLogoWhite

0

#include <iostream>

bool isPrime(int p)

{if( p<=1 ( p>2 && p%2==0 ))return( false );int max = (int)sqrt(( double ) p ) + 1;for( int i=3; i<=max; i+=2 )if( p%i==0 )return( false );return( true );

}

int main()

{

const int max=50;int primes[max];

int count=0, num=0;

while( count!=max )

{num+=num>2?2:1;if( isPrime(num) )primes[count++]=num;}for( int i=0; i<max; ++i )std::cout << primes[i] << std::endl;return( 0 );

}

User Avatar

Wiki User

12y ago

What else can I help you with?

Related Questions

Is 5291 a prime number using 2 numbers?

No 5291 is not a prime using 2 numbers. It is a prime using three numbers.


Does the first two numbers have to be the greatest number that goes into another number when using prime factoriation?

No.


Program for print prime all number from 1 to 100 in foxpro?

Oh, what a lovely request! In FoxPro, you can create a program to print all prime numbers from 1 to 100 by using a loop to check each number for divisibility only by 1 and itself. If it meets this criteria, you can print it out on the screen. Remember, every number is unique and special, just like a happy little tree in a vast forest.


How do you find rectangles using the prime numbers?

Prime numbers have one factor pair, hence one rectangle.


How to write a C program to find largest 2 numbers using pointers?

program to find maximum of two numbers using pointers


What is the product of 40 using prIme numbers?

21


How do you get 12 using prime numbers?

2x2x3 = 12


Program to count the number of numbers in an array using 8085 microprocessor?

A program which is used to count the number of numbers in an array using a 8085 microprocessor is known as a assembly language program.


What is the prime fatorization of 78 using exponents?

No prime power exists since there are no duplicate prime numbers in the prime factorization.


Prime number using the exponent of 70?

No prime power exists since there are no duplicate prime numbers in the prime factorization.


What are the prime factors using exponents of 78?

No prime power exists since there are no duplicate prime numbers in the prime factorization.


Prime factorization of 19 using exponents?

No prime power exists since there are no duplicate prime numbers in the prime factorization.