File:  [CSRG BSD Unix] / 43BSD / contrib / B / ex / pi / 'PI
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Tue Apr 24 16:12:54 2018 UTC (8 years, 1 month ago) by root
Branches: MAIN, BSD
CVS tags: HEAD, BSD43
BSD 4.3

HOW'TO PI n':
	\Print the first n places of pi. a, b, c and d get very large.
	WRITE '3.'
	PUT n' IN n
	PUT 3, 0, 40, 4, 24, 0, 1 IN k, a, b, c, d, e, f
	WHILE n>0:
		WHILE e=f AND n>0:
			WRITE e<<1
			PUT n-1 IN n
			PUT 10*(a-e*c), 10*(b-f*d) IN a, b
			PUT floor(a/c), floor(b/d) IN e, f
		PUT k**2, 2*k+1, k+1 IN p, q, k
		PUT b, p*a+q*b, d, p*c+q*d IN a, b, c, d
		PUT f, floor(b/d) IN e, f
	WRITE /

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.