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
How do you answer other peoples questions on Brainly? I know how to ask them but not answer hmm...
Oliga [24]

Answer:

simply click the main brainly logo at the top left and it will drop you a feed. then look around for questions you want to answer and click it, then after click add answer. type your response

8 0
2 years ago
A user who enters americanbank.net into a web browser instead of the correct americanbank and is then taken to a fake look-alike
Vlada [557]

Answer:

Typosquatting is the correct answer.

Explanation:

Typosquatting is another type of cybersquatting in which any user or person enters into the others sites from the web browser and then, they create another fake that is usually same as that site. They also create that type of address of the fake websites that is somewhere similar to the original and these are illegal in many countries.

6 0
4 years ago
Read 2 more answers
Zara is typing the names of all the States in Pakistan. She has not numbered the list. Suggest her the way by which she can numb
Pavel [41]

Answer:

Following are the steps that Zara  is taking to numbered the list is given below .

Explanation:

  • Choose the names of the states to be numbered.
  • Choose the Insert menu bar option. After that click from there on the Bullets and Numbering option.
  • After that different lists will show representing the numbering in different ways.
  • Select the numbering type option that you'd like to implement, and press ok button on it .
  • Finally the names of the state of Pakistan is numbered .

7 0
3 years ago
Qu'est-ce qui motive le choix d'une autre?
Monica [59]

Actions are important because they have real-world consequences, but in seeking to understand our own and other people’s actions, it works better to have an understanding of how an action is motivated by the beliefs and values that underlie it.

Explanation:

  • The reason or reasons one has for acting or behaving in a particular way. Motivation is also defined as the general desire or willingness of someone to do something.
  • It is crucial for all of us to realize that motivation is a choice. It is entirely up to us to motivate ourselves to do what it takes to reach our goals.
  • Everything you need is in your mind, and you alone can influence that feeling of motivation
  • People exhibit roughly equal amounts of love and selfishness, and we identify people whose balance is more loving or more selfish and make choices about which we want more of in our own lives.
  • The motivation scale is one way of thinking about how we gain what we want and who is affected by our choices.
  • Your values, priorities, purpose, goals, drive, learning, love, and hope all live in motivation.
8 0
3 years ago
Before you start creating a database, you should first use paper to plan, test, and revise. True False
Licemer1 [7]
<span>Before you start creating a database, you should first use paper to plan, test, and revise. True or False?
TRUE</span>
8 0
4 years ago
Read 2 more answers
Other questions:
  • In a typical system design specification, the _____ section contains the complete design for a new system, including the user in
    5·1 answer
  • To activate a wizard to help in creating combo boxes and command buttons, make sure the ____ button is selected
    6·1 answer
  • If totalMonths has a string value of "13", what does the code that follows display?var years = parseInt ( totalMonths / 12 );var
    6·1 answer
  • In the following data definition, assume that List2 begins at offset 2000h. What is the offset of the third value (5)?
    10·1 answer
  • You have a manager who makes decisions without getting input from anyone. They are unwilling to change anything once a decision
    14·1 answer
  • The following is a true example of a computer: A. Toyota Camry
    12·1 answer
  • Consider we have n pointers that need to be swizzled, and swizzling one point will take time t on average. Suppose that if we sw
    11·1 answer
  • The introduction of an academic paper must include a:
    12·2 answers
  • Malware that locks or prevents a device from functioning properly until a fee has been paid is known as:
    11·1 answer
  • A pcr-based method to detect a specific pathogen in a specimen works by amplifying a ________ that is specific to the prospected
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!