これはStackoverflowに関する私の最初の質問です。何か間違ったことをしている場合は、すみません。:)このコードを手伝ってくれませんか?ありがとうございました!:)
#include <iostream>
using namespace std;
1)
int divisor(int a) // function that checks the divisors of a number *)
{
int i=1; // counter
while(i<=a) // while the counter is less than the number given
{
int i;
if(primes(i)) // here i get the error "primes was not declared in this scope
{
if(a%i==0) // if the remainder of the operation is 0, the number is a divisor
{
cout<<"The divisors of the number are: "<<i<<endl; // prints the divisors
++i; // counter is incremented
}
}
else // else it is not, and the counter i is incremented
{
++i;
}
}
}
2)
int primes(int number) // checks if a number is prime
{
int i;
for(i=2;i<number;i++) // for loop until the counter i is less than a number
{
if(number%i==0) // if the remainder of the operation is 0, the number is not prime
{
break;
}
else //else the number is prime
cout<<number;
break;
}
}
}
3)
int main()
{
int n,i;
cout<<"Give the number: ";
cin>>n;
for(i=2;i<n;i++)
{
divisor(n);
}
}