The program must run with not errors and the code must be in c++ with no doubles
ID: 3539118 • Letter: T
Question
The program must run with not errors and the code must be in c++ with no doubles
Just another sequence, The Funny Sequence Funny numbers are numbers whose only prime factors are 2, 3 or 5. The sequence 1, 2, 3, 4, 5, 6, 8, 9, 10, 12, 15, ... shows the first 11 funny numbers. By convention, 1 is included. Write a program to find and print the 1501'st funny/ugly number. Input and Output There is no input to this program. Output should consist of a single line as shown below, with <number> replaced by the number computed. Sample output The 1501'st ugly number is <number>.
Explanation / Answer
#include <iostream>
using namespace std;
int main()
{
int i=1,cou=0;
while(1)
{
if(i%2==0 || i%3==0 || i%5==0)
cou++;
if(cou==1500)
{
cout<<"the number is"<<i;
return 0;
}
i++;
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.