🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: pl.comp.lang.vbasic
3 messages
3 total messages Started by Wan Li Zhu Thu, 20 Nov 1997 22:25
Problem with VB for next loop
#171
Author: Wan Li Zhu
Date: Thu, 20 Nov 1997 22:25
8 lines
1045 bytes
    Hi, I'm trying to make a program in VB 4.0 to calculate pi with the
following formula:

pi/4 = 2/3 * 4/3 * 4/5 * 6/5 * 6/7 * 8/7 *...

I just couldn't figure out how to do this with the For-Next loop in VB
and would really appreciate it if anyone can offer me some hint/help.
Thank you!
Re: Problem with VB for next loop
#172
Author: Ishida
Date: Fri, 21 Nov 1997 12:58
31 lines
1528 bytes
My name is Ishida.
I  don't understand English.

> pi/4 = 2/3 * 4/3 * 4/5 * 6/5 * 6/7 * 8/7 *...
> 
> I just couldn't figure out how to do this with the For-Next loop in VB
> and would really appreciate it if anyone can offer me some hint/help.
> Thank you!

I don't understand meaning of "pi/4 = " .

/////////////////////////////////////
logic of
i = 2/3 * 4/3 * 4/5 * 6/5 * 6/7 * 8/7 *...
/////////////////////////////////////
Dim i As Integer
Dim Result  as Double

Result = 0
Result = 2/3

For i = 3 To LoopCount
    if mod(i/2) = 0 then
        Result = Result * ( i / (i+1) ) 
    Else
        Result = Result * ( (i+1) / i )
    End If
Next i

----------------------------
 I will be of help to you.
Re: Problem with VB for next loop
#173
Author: Dick Harrison
Date: Fri, 21 Nov 1997 13:36
19 lines
1182 bytes
Wan Li Zhu

Try:

Dim temp As Double
Dim count As Integer

temp = 0
For count  = 2 To 1000 Step 2 ' where 1000 is your choice
    temp = temp * (count / (count - 1))
    temp = temp * (count / (count + 1))
Next count

Pi = temp * 8

Something like that, anyway.

Regards
Dick
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads