File: pi.rb

package info (click to toggle)
ruby2.1 2.1.5-2%2Bdeb8u3
  • links: PTS, VCS
  • area: main
  • in suites: jessie
  • size: 60,088 kB
  • ctags: 69,767
  • sloc: ruby: 625,741; ansic: 295,223; xml: 25,445; yacc: 9,155; lisp: 2,433; tcl: 949; makefile: 535; sh: 402; perl: 62; python: 47; awk: 36; asm: 35; sed: 31
file content (20 lines) | stat: -rw-r--r-- 350 bytes parent folder | download | duplicates (16)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/usr/local/bin/ruby

#
# pi.rb
#
# Calculates 3.1415.... (the number of times that a circle's diameter
# will fit around the circle) using J. Machin's formula.
#

require "bigdecimal"
require "bigdecimal/math.rb"

include BigMath

if ARGV.size == 1
    print "PI("+ARGV[0]+"):\n"
    p PI(ARGV[0].to_i)
else
    print "TRY: ruby pi.rb 1000 \n"
end