i dont under stand .wht u wnt to say?
this is code to chek whteher given number is prime or not...now question is that where should be loop held to take decrement and chek again till it reaches 1???
#include<iostream>
using namespace std;
int main()
{
int c=0;
int a;
int k=1;
cin>>a;
while(k<=a)
{
if(a%k==0)
{
c=c+1;
}
k++;
}
if(c==2)
{
cout<<"prime"<<a;
#include <iostream>
int main() {
int a;
std::cin >> a;
for (a; a > 1; --a) {
int c = 0, k = 1;
while (k <= a) {
if (a % k == 0) {
c += 1;
}
k++;
}
if (c == 2) {
std::cout << "prime " << a;
} else {
std::cout << "not prime " << a;
}
std::cout << std::endl;
}
}
for(unsignedint x = 0; x < INFINITY /* INFINITY is defined */; x++)
{
if((x % 2) == 1)
{
cout<< "i found it, I FOUND IT."<< endl;
}
}
Probably one of the easiest things you could do. I suggest you study the code and figure out the mechanics involved, as you will be using them in everything.
Oops, that finds odd/even numbers. You want to write an algorithm to factor each number.