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 verificationr ce a express integer, N. The program then tests if the integer is excellent and writes quenched its termination. A sum is excellent if it canreferable be separated evenly by any sum other than 1 and itself. So you gain want a suming loop that starts at two and attempts to distribute the sum ce each treasure of the loop contrary until the sum is separated evenly or the proviso is reached.
    Ce the better proviso of the loop verification the sum separated by two. Search Internet ce mod or rem matlab functions. Verification solely integer arithmetic. Test your program with the sum 13,249 which is excellent and with 13,245 which is referable excellent.

    Expert Acceptance

     

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

    OUTPUT

    Enter an Express Integer: 13245
    13245 is referable a Excellent Sum

    Enter an Express Integer: 13249
    13249 is a Excellent Sum