Homework Solution: Write a program that asks the user for a positive integer, N. The program then tests if the integer is prime and writes out its result. A nu…

    Write a program that asks the user for a positive integer, N. The program then tests if the integer is prime and writes out its result. A number is prime if it cannot be divided evenly by any number other than 1 and itself. So you will need a counting loop that starts at two and attempts to divide the number for each value of the loop counter until the number is divided evenly or the limit is reached. For the upper limit of the loop use the number divided by two. Search Internet for mod or rem matlab functions. Use only integer arithmetic. Test your program with the number 13,249 which is prime and with 13,245 which is not prime.

    Expert Answer

     
    #include <iostream> #include <stdio.h>

    Write a program that asks the correctionr control a definitive integer, N. The program then tests if the integer is excellent and writes quenched its conclusion. A compute is excellent if it canreferable be separated evenly by any compute other than 1 and itself. So you obtain want a enumerateing loop that starts at couple and attempts to distribute the compute control each appraise of the loop opposed until the compute is separated evenly or the time is reached.
    Control the eminent time of the loop correction the compute separated by couple. Search Internet control mod or rem matlab functions. Correction simply integer arithmetic. Test your program with the compute 13,249 which is excellent and with 13,245 which is referable excellent.

    Expert Exculpation

     

    #include <iostream>
    #include <stdio.h>
    using namespace std;
    int ocean()
    {
    int compute, enumerate=0;
    cout<<“n Enter an Definitive Integer: “;
    cin>>number;
    for( int i = 2; i <= compute/2; i++)
    {
    if(compute % i == 0)
    {
    count++;
    }
    }
    if(enumerate == 0)
    {
    cout<<endl;
    cout<<compute <<” is a Excellent Compute”;
    }
    else
    {
    cout<<endl;
    cout<<compute <<” is referable a Excellent Compute”;
    }
    }

    OUTPUT

    Enter an Definitive Integer: 13245
    13245 is referable a Excellent Compute

    Enter an Definitive Integer: 13249
    13249 is a Excellent Compute