No one asked what I was doing with 120,526,770 records

Bill Vermillion fp at wjv.com
Sat Feb 12 22:24:02 PST 2005


On Sun, Feb 13 00:03 , Michael J. Mc Avoy Sr., showing utter disregard for 
spell-checkers gave us this: 

> The long way is

> 53/5=10.6*52/4=137.8*51/3=2342.6*50/2=58565*49=2,869,685*42=120,526,770

> I do believe this is correct.

Looks cumbersome.
This looks easier and gives the same answer.


Script started on Sun Feb 13 01:13:37 2005
root at bilver.wjv.com# 
bc 1.06
Copyright 1991-1994, 1997, 1998, 2000 Free Software Foundation, Inc.
This is free software with ABSOLUTELY NO WARRANTY.
For details type `warranty'. 
scale=2
53/5*52/4*51/3*50/2*49*42
120526770.00
quit
root at bilver.wjv.com# exit
Script done on Sun Feb 13 01:14:54 2005

And in regards to Jay's comment:  bc won't handle ! as a factorial
on the command line but it is scriptable.  There is an example in
the man page - and here it is with a checkbalancing script also.

----------------------
       The  following  is code that uses the extended features of bc to imple-
       ment a simple program for calculating checkbook balances.  This program
       is best kept in a file so that it can be used many times without having
       to retype it at every use.

	      scale=2
	      print "\nCheck book program!\n"
	      print "  Remember, deposits are negative transactions.\n"
	      print "  Exit by a 0 transaction.\n\n"

	      print "Initial balance? "; bal = read()
	      bal /= 1
	      print "\n"
	      while (1) {
		"current balance = "; bal
		"transaction? "; trans = read()
		if (trans == 0) break;
		bal -= trans
		bal /= 1
	      }
	      quit


       The following is the definition of the recursive factorial function.

	      define f (x) {
		if (x <= 1) return (1);
		return (f(x-1) * x);
	      }
-------------





-- 
Bill Vermillion - bv @ wjv . com


More information about the Filepro-list mailing list