inweb-bootstrap/Tests/Test Cases/_Tangled_Ideal/twinprimes.txt
2020-04-15 23:45:08 +01:00

33 lines
819 B
Text

/* Tangled output generated by inweb: do not edit */
#include <stdio.h>
#define RANGE 100 /* the upper limit to the numbers we will consider */
#define TRUE 1
#define FALSE 0
#line 27 "inweb/Tests/Test Cases/twinprimes.inweb"
int main(int argc, char *argv[]) ;
#line 48 "inweb/Tests/Test Cases/twinprimes.inweb"
int isprime(int n) ;
#line 26 "inweb/Tests/Test Cases/twinprimes.inweb"
int main(int argc, char *argv[]) {
for (int i=1; i<RANGE; i++)
{
#line 33 "inweb/Tests/Test Cases/twinprimes.inweb"
if ((isprime(i)) && (isprime(i+2)))
printf("%d and %d\n", i, i+2);
}
#line 29 "inweb/Tests/Test Cases/twinprimes.inweb"
;
}
#line 48 "inweb/Tests/Test Cases/twinprimes.inweb"
int isprime(int n) {
if (n <= 1) return FALSE;
for (int m = 2; m*m <= n; m++)
if (n % m == 0)
return FALSE;
return TRUE;
}