Help with calculating pi in code!!

coffee

New member
Joined
Feb 17, 2009
Messages
3
Programming Experience
Beginner
I am new to vb.net and am having issues with this problem that i need to complete. Is there someone that can help me?

It should be a basic loop code, I just can't figure it out.

THANKS!!


The value of pi can be determined by the series equation:

pi = 4*(1/3 + 1/5 + 1/7 + 1/9 + 1/11 + ....)


Write a console program that will ask the user to enter the number of terms to use to approximate pi, calculate the approximation, and then output the result to the screen.
 
Last edited by a moderator:
1. We dont mind helping you, but you have to make some form of attempt at it rather than have us do all the work.

2. When asking a question, please you make sure you ask the question correctly - I dont believe that is the way to calculate pi :D I suggest you check again.
 
Inertia is right. You do need to work on the code yourself, but I will give you a hint in psuedocode

VB.NET:
Dim pi As Double = 1 ' seed pi
Dim i As UInt16 = 0 ' seed the index

While i < 100 ' or however many times you want this process to be repeated
i += 2 'count by twos to get only odd numbers

pi += 4 * Math.Pow(i,-1) ' add by distribution

End While

ok so maybe not psuedocode..but you still need to attempt or give us your attempt before you just ask for help...you'll never get anywhere that way
 

Latest posts

Back
Top