I've made a piece of code that just will not work, what's wrong! It can execute fine, but calculates everything as being non prime!
Thanks in advance!
Code:
# include <iostream>
# include <cstdlib>
# include <cmath>
using namespace std;
int main ()
(
int t, c, residue;
char in;
Cout << "Enter the number you want tested for primtalisme, then enter: \ n \ n";
cin>> t;
c = t;
if (t == 0, t == 1, t == 2)
(
Cout << "yes";
Cout <<c;
Cout << "suffering from primtalisme012 \ n \ n";
return 0;
)
else
(
for (i = 2; i <= (c-1); i + +)
(
if (c% in == 0)
(
residual = 0;
break;
)
else
(
residual = 1;
)
)
if (remainder == 0)
(
Cout << "yes";
Cout <<c;
Cout << "suffering from primtalisme other \ n \ n";
)
else
(
Cout << "no";
Cout <<c;
Cout << "suffer not the primtalisme \ n \ n";
)
)
return 0;
)
PS. I know there are other methods, but why does this not?
Bookmarks