Write a program that asks the user to enter a positive number then displays all numbers
less or equal to it that are prime each one a separate line.
1
Expert's answer
2015-11-19T04:17:08-0500
#include <iostream> #include <math.h> using namespace std; int main (){ int n = 0; int divisor =2; cout<<"Please input a positive number n = "; cin>>n; for( int i=3;i<=n;i++){ for ( int j = divisor;j<=(round(0.5*i)+1);j++){ if ((i%j)==0) break; if (j==round(0.5*i)+1) cout<<i<<endl; } } cout<<"Program Finished"; return 0; }
Numbers and figures are an essential part of our world, necessary for almost everything we do every day. As important…
APPROVED BY CLIENTS
Finding a professional expert in "partial differential equations" in the advanced level is difficult.
You can find this expert in "Assignmentexpert.com" with confidence.
Exceptional experts! I appreciate your help. God bless you!
Comments
Leave a comment