**Task: Calculate Digits of Pi in Atari BASIC**

**Needed: BASIC**

**Time: 10-15 mins**

**Introduction**

The number pi (~ 3.14159265359) is a constant defined as the ratio of a circle’s circumference to its diameter. It has fascinated mathematicians for ages given the pattern of decimal values goes on forever and never repeats. A favorite pastime is to use computers to find as many digits of pi as possible. As of 2020, the record was 50 trillion digits using the y-cruncher algorithm.

There is a web page with programs for calculating pi in many different languages including Atari BASIC. I have entered this code, verified that it works, and saved it in an ATR file (see below).

**Instructions**

Here is an ATR file with the BASIC code which can loaded an run on the Atari or Altirra.

You can also copy and paste the BASIC code from the web page directly into Altirra and run it that way. It is short and will only take a few seconds to paste in.

Once loaded from the ATR (e.g. LOAD “D:PI.BAS” in BASIC) simply type RUN.

**Comments**

This code is REALLY slow. I have it set to calculate the first 10 digits. This should take about five minutes or so. You can shorten or lengthen the number of digits by changing line 20. It is fun to see though where the state of pi mathematics was back in 1979 on an 8-bit home computer.