File: harmonic.sh

package info (click to toggle)
saml 970418-3
  • links: PTS
  • area: main
  • in suites: slink
  • size: 1,204 kB
  • ctags: 1,701
  • sloc: ansic: 17,182; sh: 2,583; yacc: 497; perl: 264; makefile: 250; python: 242
file content (10 lines) | stat: -rwxr-xr-x 345 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
#!/bin/sh
#
# Computes 1 + 1/2 + 1/3 + ... +1/2000  using induce
#
# Note that it isn't exactly equivalent to the python version, since
# induce works on polynomials with rational coefficients, instead of
# rational numbers. So the induce version is slightly disadvantaged in the
# comparison.
#
exec induce -e 'H[0]=0;H[n]=H[n-1]+1/n;' H[2000]