Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

/PROG/ Challenge Number 3 - Pi

Name: Anonymous 2007-09-13 22:45 ID:IZip/Yni

Make a program to calculate pi to the n'th decimal. Input the variable at runtime.  Program In the language of you choice. (and none of the print"3.1415" crap.)

Name: Anonymous 2007-09-13 22:49 ID:/BBjeZZn

JAVA LOL
FINDING PI METHOD #1

import java.util.Random;
public class PiFinder
{
    public double piSeries(int numberOfTerms)
    {
        boolean add = true;
        double answer = 0.0;
        double first = 1.0;
        while (numberOfTerms > 0) {
            if (add) {
                answer += (1 / first);
                first += 2;
                add = false;
                numberOfTerms--;
               }
            else {
                answer -= (1 / first);
                first += 2;
                add = true;
                numberOfTerms--;
               }
           }
            return (answer * 4);
    }
}




Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List