inweb-bootstrap/Tests/Test Cases/_Tangled_Ideal/twinprimes.txt
2019-02-04 22:26:45 +00:00

36 lines
820 B
Text

#ifndef PLATFORM_WINDOWS
#define PLATFORM_POSIX
#endif
/* Tangled output generated by inweb: do not edit */
#include <stdio.h>
#define RANGE 100
#define TRUE 1
#define FALSE 0
#line 21 "inweb/Tests/Test Cases/twinprimes.inweb"
int main(int argc, char *argv[]) ;
#line 46 "inweb/Tests/Test Cases/twinprimes.inweb"
int isprime(int n) ;
#line 20 "inweb/Tests/Test Cases/twinprimes.inweb"
int main(int argc, char *argv[]) {
for (int i=1; i<RANGE; i++)
{
#line 27 "inweb/Tests/Test Cases/twinprimes.inweb"
if ((isprime(i)) && (isprime(i+2)))
printf("%d and %d\n", i, i+2);
}
#line 23 "inweb/Tests/Test Cases/twinprimes.inweb"
;
}
#line 46 "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;
}