1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Grace [21]
3 years ago
6

Write a program that declares an array of size 1,230 and stores the first 1,230 prime numbers in this array. The program then us

es the first 1,230 prime numbers to determine if a number between 2 and 100,000,000 is prime. If a number is not prime, then output at least one of its prime factors.
Computers and Technology
1 answer:
timurjin [86]3 years ago
3 0

Answer:

The complete question is :

A positive integer n is called prime if n > 1 and the only factors of n are 1 and n. It is known that the positive integer n>1 is prime if n is not divisible by any prime integer m≤n. The 1230th prime number is 10,007. Let t be an integer such that 2≤t≤100,000,000. Then t is prime if either t is equal to one of the first 1230 prime numbers or t is not divisible by any of the first 1230 prime numbers. Write a program that declares an array of size 1,230 and stores the first 1,230 prime numbers in this array. The program then uses the first 1,230 prime numbers to determine if a number between 2 and 100,000,000 is prime. If a number is not prime, then output at least one of its prime factors.

Explanation:

The program is :

#include<iostream>  

#include<cmath>  

using namespace std;  

const int SIZE = 1230;  

bool isPrime(int number);  

void first1230PrimeNum(int list[], int length);  

void primeTest(int num, int list[], int length);

int main()  

{

   int primeList[SIZE];

   int number;

    first1230PrimeNum(primeList, SIZE);

    cout<<"Enter an integer between 2 and 100,000,000: ";

    cin>>number;

    cout<<endl;

    primeTest(number, primeList, SIZE);

    system("pause");

     return 0;

}  

bool isPrime(int number)  

{

 int i; //to iterate

  //loop till sqrt(number)

    for(i=2; i<=sqrt(number); i++)

      {

         //if any factor

         if(number%i == 0)

          return false;//return false

     }

        return true; //otherwise return true

}  

void first1230PrimeNum(int list[], int length)  

{

 int i=0, number = 2; //i to itrate and number to test prime

 while(i<length) //get 1230 primes

   {

    if(isPrime(number)) //check if prime or not

    {

      list[i] = number; //add it to list

      i++; //increment i

    }

 number++; //increment number

  }  

}  

void primeTest(int num, int list[], int length)  

{

int i; //i to iterate

 //loop through list

 for(i=0; i<length; i++)

{

//if num is in list then it is prime

  if(num == list[i])

 {

  cout<<num<<" is a prime"<<endl;

   return;

   }

   //if divisible by any number then not a prime

    if(num % list[i] == 0)

{

  cout<<num<<" is not a prime"<<endl;

   cout<<"One of the prime factor: "<<list[i]<<endl;

   return;

 }

}

cout<<num<<" is a prime"<<endl;  

}

OUTPUT :

Enter an integer between 2 and 100,000,000 : 104659

104659 is a prime.

You might be interested in
An article explaining the uses of the parts of a computer​
Luda [366]

Answer:

A infographic article is what you are talking about

4 0
3 years ago
Raul in Colombia can enter data into a spreadsheet. Olivia in England can access the spreadsheet a few minutes later and use Rau
Mila [183]

True, as long as the application is a cloud-based spreadsheet (like Google Docs or MS Office 365), which allows multiple users in any location to view or edit the data with proper access permissions.

7 0
3 years ago
The negotiators past relationship will affect current behavior if the parties
denis-greek [22]

A. if they have been previously competetive

6 0
4 years ago
Types of Computer games​
kiruha [24]

\bold{Hello}~

\bold{Answer:}

<h3>Types of Computer games</h3>
  • Action
  • Adventure
  • Simulation
  • Sports
  • Role-playing
  • Puzzlers
  • Party games

<em>(</em><em>That's</em><em> </em><em>all</em><em> </em><em>i</em><em> </em><em>know</em><em>)</em><em> </em>

<h2>#Hopeithelps\:</h2>

\bold{-Kei}~

\tiny\sf\purple{ ♡♡♡♡♡♡♡♡♡♡♡♡♡♡♡♡♡♡♡♡♡♡♡♡♡♡♡♡♡♡♡♡♡♡♡♡♡♡♡♡♡♡♡♡♡♡♡♡♡♡♡♡ }

5 0
3 years ago
What will be the value of x after the following code is executed? int x = 10; do { x *= 20; } while (x &lt; 5); A. 10 B. 200 C.
dezoksy [38]

Answer:

Option B is the correct answer.

Explanation:

  • In the above code, the loop will execute only one time because the loop condition is false and it is the Do-While loop and the property of the Do-while loop is to execute on a single time if the loop condition is false.
  • Then the statement "x*=20;" will execute one and gives the result 200 for x variable because this statement means "x=x*20".
  • SO the 200 is the answer for the X variable which is described above and it is stated from option B. Hence it is the correct option while the other is not because--
  1. Option A states that the value is 10 but the value is 200.
  2. Option C states that this is an infinite loop but the loop is executed one time.
  3. Option D states that the loop will not be executed but the loop is executed one time
6 0
3 years ago
Read 2 more answers
Other questions:
  • What is the term for a device that converts digital data from a computer into analog signals and back again?
    9·1 answer
  • a reviewer is required to enter a reason in the comments field only when a candidate is recommended to be hired. which action ca
    8·1 answer
  • )a___ is a complete binary tree such that each node in the tree contains a comparable object that us greater than or equal to th
    9·1 answer
  • What cable should i be using to connect my android tablet to the pc?
    13·2 answers
  • describe a real-world scenario where data is collected and needs to be both accurate and precise for the safety of the community
    9·1 answer
  • In a typical e-mail address, what is the "host"? A. an account designated by a user name. B. the computer that houses an Interne
    7·1 answer
  • What are two variables is figure 1 comparing
    10·1 answer
  • You work in the Accounting department and have been using a network drive to post Excel workbook files to your file server as yo
    15·1 answer
  • The function below takes a single argument: data_list, a list containing a mix of strings and numbers. The function tries to use
    6·1 answer
  • 6. kinukuha nito ang kabuuang bilang ng mga numerical na datos sa mga piniling cells
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!