diff options
Diffstat (limited to 'pi.awk')
| -rw-r--r-- | pi.awk | 5 |
1 files changed, 4 insertions, 1 deletions
@@ -1,4 +1,4 @@ -#! /usr/bin/awk -f +#!/usr/bin/awk -f ### pi.awk, https://en.wikipedia.org/wiki/Pi # In 1706 John Machin used the Gregory–Leibniz series to produce an algorithm @@ -11,11 +11,14 @@ # Ferguson–the best approximation achieved without the aid of a calculating # device. + function pi() { return 4*(4*atan2(1,5) - atan2(1,239)) } + BEGIN { ARGV[1] ? OFMT = "%." ARGV[1] "g" : OFMT = "%g" printf(OFMT ORS, pi()) } + |
