2 This is a program to determine the distribution of digits in the
3 fraction part of PI. It will look at the first scale digits.
5 The results are left in the global variable digits.
6 digits[0] is the number of 0's in PI.
8 This program requires the math library.
12 auto ix, pi, save_scale, work;
16 print "\n\nCalculating PI to ",scale," digits. Please wait . . .";
21 print "\nCounting digits. . .";
22 for (ix = 0; ix < 10; ix++) digits[ix] = 0;
24 /* Extract the One's digit from pi. */
28 for (ix = save_scale; ix > 0; ix--) {
30 /* Remove the One's digit and multiply by 10. */
32 work = (work - one_digit) / 1 * 10;
34 /* Extract the One's digit. */
38 digits[one_digit] += 1;
41 /* Restore the scale. */
46 print "PI to ", scale, " digits is:\n", pi/1, "\n\n"
47 print "The frequency of the digits are:\n"
48 for (ix = 0; ix < 10; ix++) {
49 print " ", ix, " - ", digits[ix], " times\n"