inweb-bootstrap/Figures/tree.txt

136 lines
5.5 KiB
Text
Raw Normal View History

2020-04-23 22:23:44 +00:00
document weave order 0
2020-08-03 21:23:05 +00:00
head banner <Weave of 'The Twin Primes Conjecture' generated by Inweb>
2020-04-23 22:23:44 +00:00
body
chapter <Sections>
chapter header <Sections>
section <Main>
section header <Main>
section purpose <This example of using inweb is a whole web in a single short file, to look for twin primes, a classic problem in number theory.>
toc - <S/all>
toc line - <S1, The conjecture> P1'The conjecture'
toc line - <S2, Primality> P2'Primality'
paragraph P1'The conjecture'
material discussion
commentary <It is widely believed that there are an infinite number of twin primes, that\n>
commentary <is, prime numbers occurring in pairs different by 2. Twins are known to exist\n>
commentary <at least as far out as >
mathematics <10^{388,342}>
commentary < (as of 2016), and there are infinitely\n>
commentary <many pairs of primes closer together than about 250 (Zhang, 2013; Tao, Maynard,\n>
commentary <and many others, 2014).\n>
vskip (in comment)
commentary <This program finds a few small pairs of twins, by the simplest method possible,\n>
commentary <and should print output like so:\n>
material code: C
code line
source_code < 3 and 5>
_ppppppppppp_
code line
source_code < 5 and 7>
_ppppppppppp_
code line
source_code < 11 and 13>
_ppppppppppppp_
code line
source_code < ...>
_ppppppp_
material definition
code line
defn <define>
source_code <RANGE 100 >
_nnnnnpnnnp_
commentary < the upper limit to the numbers we will consider> (code)
material code: C
code line
source_code <#include <stdio.h>>
_piiiiiiippiiiiipip_
vskip
code line
source_code <int main(int argc, char *argv[]) {>
_rrrpffffprrrpiiiipprrrrppiiiippppp_
code line
source_code < for (int i=1; i<RANGE; i++)>
_pppprrrpprrrpippppipnnnnnppippp_
code line
source_code < >
_pppppppp_
pmac <Test for twin prime at i>
source_code <;>
_p_
code line
source_code <}>
_p_
paragraph P1.1
material paragraph macro
code line
pmac <Test for twin prime at i> (definition)
material code: C
code line
source_code < if ((>
_pppprrppp_
function usage <isprime>
source_code <(i)) && (>
_pippppppp_
function usage <isprime>
source_code <(i+2)))>
_pippppp_
code line
source_code < printf("%d and %d\n", i, i+2);>
_ppppppppiiiiiipsssssssssssssppippipppp_
material endnotes
endnote
commentary <This code is >
commentary <used in >
locale P1'The conjecture'
commentary <.>
paragraph P2'Primality'
material discussion
commentary <This simple and slow test tries to divide by every whole number at least\n>
commentary <2 and up to the square root: if none divide exactly, the number is prime.\n>
commentary <A common error with this algorithm is to check where >
mathematics <m^2 < n>
commentary <, rather\n>
commentary <than >
mathematics <m^2 \leq n>
commentary <, thus wrongly considering 4, 9, 25, 49, ... as prime:\n>
commentary <Cambridge folklore has it that this bug occurred on the first computation\n>
commentary <of the EDSAC computer on 6 May 1949.\n>
material definition
code line
defn <define>
source_code <TRUE 1>
_nnnnpn_
code line
defn <define>
source_code <FALSE 0>
_nnnnnpn_
material code: C
code line
source_code <int >
_rrrp_
function defn <isprime>
locale P1.1
source_code <(int n) {>
_prrrpippp_
code line
source_code < if (n <= 1) return FALSE;>
_pppprrppippppnpprrrrrrpnnnnnp_
code line
source_code < for (int m = 2; m*m <= n; m++)>
_pppprrrpprrrpipppnppipippppippippp_
code line
source_code < if (n % m == 0)>
_pppppppprrppipppippppnp_
code line
source_code < return FALSE;>
_pppppppppppprrrrrrpnnnnnp_
code line
source_code < return TRUE;>
_pppprrrrrrpnnnnp_
code line
source_code <}>
_p_
section footer <Main>
chapter footer <Sections>
tail rennab <End of weave>