Skip to content

Commit

Permalink
fix example
Browse files Browse the repository at this point in the history
  • Loading branch information
Laplace-Demon authored and zapashcanon committed Jul 26, 2024
1 parent 54d3bf9 commit e5492ee
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions example/c/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ Consider the following (faulty) function `primes`, it implements the algorithm o
void primes(int *is_prime, int n) {
for (int i = 1; i < n; ++i) is_prime[i] = 1;
for (int i = 2; i * i < n; ++i) {
if (is_prime[i] == 0) continue;
if (!is_prime[i]) continue;
for (int j = i; i * j < n; ++j) {
is_prime[i * j] = 0;
}
Expand All @@ -312,7 +312,7 @@ In order to verify the implementation, we annotate the function `primes` using t
void primes(int *is_prime, int n) {
for (int i = 0; i < n; ++i) is_prime[i] = 1;
for (int i = 2; i * i < n; ++i) {
if (is_prime[i] == 0) continue;
if (!is_prime[i]) continue;
for (int j = i; i * j < n; ++j) {
is_prime[i * j] = 0;
}
Expand Down Expand Up @@ -345,7 +345,7 @@ We can then call the function with symbolic values and see what happens. We shou
void primes(int *is_prime, int n) {
for (int i = 0; i < n; ++i) is_prime[i] = 1;
for (int i = 2; i * i < n; ++i) {
if (is_prime[i] == 0) continue;
if (!is_prime[i]) continue;
for (int j = i; i * j < n; ++j) {
is_prime[i * j] = 0;
}
Expand Down Expand Up @@ -397,7 +397,7 @@ void primes(int *is_prime, int n) {
for (int i = 0; i < n; ++i) is_prime[i] = 1;
is_prime[0] = is_prime[1] = 0;
for (int i = 2; i * i < n; ++i) {
if (is_prime[i] == 0) continue;
if (!is_prime[i]) continue;
for (int j = i; i * j < n; ++j) {
is_prime[i * j] = 0;
}
Expand Down
2 changes: 1 addition & 1 deletion example/c/primes.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
void primes(int *is_prime, int n) {
for (int i = 0; i < n; ++i) is_prime[i] = 1;
for (int i = 2; i * i < n; ++i) {
if (is_prime[i] == 0) continue;
if (!is_prime[i]) continue;
for (int j = i; i * j < n; ++j) {
is_prime[i * j] = 0;
}
Expand Down
2 changes: 1 addition & 1 deletion example/c/primes2.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ void primes(int *is_prime, int n) {
for (int i = 0; i < n; ++i) is_prime[i] = 1;
is_prime[0] = is_prime[1] = 0;
for (int i = 2; i * i < n; ++i) {
if (is_prime[i] == 0) continue;
if (!is_prime[i]) continue;
for (int j = i; i * j < n; ++j) {
is_prime[i * j] = 0;
}
Expand Down

0 comments on commit e5492ee

Please sign in to comment.