Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 5 of 5

Thread: finding pi

  1. #1
    Junior Member
    Join Date
    Nov 2010
    Posts
    28
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default finding pi

    i am working on a program that calculates
    pi=4*(1-1/3+1/5-1/7+1/9-1/11+1/13+...)

    etc i know im going to use a for loop for this because i need 30000 terms to approximate the value

    can anybody help me in implementing this? any ideas would help and will be much appreciated


  2. #2
    Member Darryl.Burke's Avatar
    Join Date
    Mar 2010
    Location
    Madgaon, Goa, India
    Posts
    494
    Thanks
    8
    Thanked 48 Times in 46 Posts

    Default Re: finding pi

    That's not the way a forum works. Post your best efforts and ask a specific question. Note that "How do I do this?" is non-specific.

    Recommended reading:
    How To Ask Questions The Smart Way

    db

  3. #3
    Member
    Join Date
    Oct 2010
    Location
    Denver, CO
    Posts
    55
    Thanks
    1
    Thanked 30 Times in 29 Posts

    Default Re: finding pi

    Sounds like you either need a program to find 30,000 prime numbers or a file with them stored. To start with.....nevermind, they are just odd, not prime?
    Last edited by Zula; November 2nd, 2010 at 02:34 PM.

  4. #4
    Member
    Join Date
    Oct 2010
    Location
    Denver, CO
    Posts
    55
    Thanks
    1
    Thanked 30 Times in 29 Posts

    Default Re: finding pi

    Looks that this would do it..
    	edited

    This will do much more than 30,000 terms, but when limited to 30,000 I get
    30000: 4*0.7853898300641171 = 3.1415593202564684
    Last edited by copeg; November 2nd, 2010 at 05:11 PM.

  5. #5
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,318
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: finding pi

    Please do not post full solutions to problems such as this. The intent of these forums is to get folks to try to do things themselves and maybe even learn in the process - either through trial and error and/or trial and success.

    gonfreecks, I suggest you attempt writing this code yourself, and if it doesn't work by all means post back with a specific question about the code, what output you expect versus what you get

Similar Threads

  1. How to find location of ipaddress using Java
    By tej in forum Java Networking
    Replies: 8
    Last Post: September 8th, 2012, 06:05 AM
  2. Finding the Average
    By KiwiFlan in forum What's Wrong With My Code?
    Replies: 1
    Last Post: September 16th, 2010, 07:58 PM
  3. [SOLVED] Finding acm package
    By javapenguin in forum What's Wrong With My Code?
    Replies: 1
    Last Post: June 12th, 2010, 11:50 AM
  4. finding String in a file
    By nasi in forum Java Theory & Questions
    Replies: 12
    Last Post: May 31st, 2010, 01:16 PM
  5. Replies: 13
    Last Post: May 6th, 2009, 09:27 AM