Algorithm 2: Dividing peers will not be tested, research is limited to odd dividers
Code:
/************************** \
* * xyz_abc1.c
\ **************************/
/ * Algorithm: exclude even numbers and
* Test all dividers * /
# include <stdio.h>
int main (void)
(
int i, nb, count, test;
test = count = 0;
printf ( "Enter integer");
if (scanf ( "% d", & nb)! = 1)
return -1;
if (nb% 2 == 0)
test = 1;
else (
for (i = 3; i <nb i + = 2, count + +)
if (nb% i == 0)
test = 1;
)
if (! test)
printf ( "% d prime number, many iterations =% d \ n",
nb, count);
else
printf ( "% d is not the first number, many iterations =% d \ n", nb, count);
return 0;
)
Bookmarks