repo.or.cz
/
C-Programming-Examples.git
/
commitdiff
summary
|
log
|
graphiclog1
|
graphiclog2
|
commit
|
commitdiff
|
tree
|
refs
|
edit
|
fork
raw
|
patch
|
inline
|
side by side
(parent:
ec2f7c2
)
Bug found in Primes program.
author
Steven Schronk
<
[email protected]
>
Thu, 24 Jun 2010 18:39:06 +0000
(24 13:39 -0500)
committer
Steven Schronk
<
[email protected]
>
Thu, 24 Jun 2010 18:39:06 +0000
(24 13:39 -0500)
primes.c
patch
|
blob
|
blame
|
history
diff --git
a/primes.c
b/primes.c
index
4de08eb
..
f77190f
100644
(file)
--- a/
primes.c
+++ b/
primes.c
@@
-21,12
+21,11
@@
int main(void)
int isPrime(int n)
{
- int dev = 2;
- n = n / 2; /* optimization for algorithm */
- while(dev < n)
- {
- if(n % dev == 0) { return false; }
- dev++;
- }
+ int dev;
+
+ for(dev = 2; dev <= n/2; dev++)
+ {
+ if((n % dev) == 0) { return false; }
+ }
return true;
}