if (prime(limit) == 1){
cout << " *";
primesum++;
primesum2 += limit;
}
//This ends the line after everything has been written
cout << endl;
}
cout << "The number of prime numbers is " << primesum << endl;
cout << "The average of the prime numbers is " << primesum2/primesum << endl;
return 0;
}
int sumdivisors (int divisor){
int sum = 0;
for(int numb = 0; numb<=divisor; numb++)
if(divisor%numb == 0)
sum += numb;
return sum;
}
It should work yet every time I run it, it only prints:
Last login: Mon Sep 29 20:29:07 on console
Christians-MacBook-Pro:~ Soul$ /Applications/CodeBlocks.app/Contents/MacOS/cb_console_runner DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:. /Users/Soul/Documents/School/CISC/Assignment4/bin/Debug/Assignment4
Number Divisors Prime
Process returned -1 (0xFFFFFFFF) execution time : 0.187 s
It is supposed to show the number, the sum of the divisors and add a * if it is prime.