|
-
Oct 9th, 2000, 01:19 PM
#1
Thread Starter
New Member
How would I write a program in VB that displays fibinootchi numbers?
-
Oct 9th, 2000, 01:31 PM
#2
Junior Member
the C++ solution is as follows. You can easily convert this algorithm to VB code. This code specifically prints 5 numbers per line. Use an array where you see 'data'. I was using a vector declared as:
vector <int> data; (same as data[i])
Email me directly with further questions:
[email protected]
fibonacci(number)
{
for ( int i = 2; i < number; i++ )
{
if ( i > 1 )
{
if ( bolWritten == false )
{
printf("%12d%12d", data.at(0),data.at(1));
bolWritten = true;
intItemOnLine = 3;
}
data.push_back( data.at(i-1) + data.at(i - 2) );
if ( intItemOnLine < 5 )
{
printf("%12d", data.at(i));
intItemOnLine++;
}
else
{
printf("%12d\n", data.at(i));
intItemOnLine = 1;
}
} // end if
} // end for
} // end function
-
Oct 9th, 2000, 01:59 PM
#3
Fanatic Member
I once wrote a program for doing that. Past this into notepad and save it as a .frm file:
Code:
VERSION 5.00
Begin VB.Form Fibonacci
BorderStyle = 3 'Fixed Dialog
Caption = "Calculate fibonacci's with strings!"
ClientHeight = 24
ClientLeft = 48
ClientTop = 336
ClientWidth = 5388
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 24
ScaleWidth = 5388
ShowInTaskbar = 0 'False
StartUpPosition = 3 'Windows Default
End
Attribute VB_Name = "Fibonacci"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim Running As Boolean
Private Function Telop(Getal1 As String, Getal2 As String) As String
'Getal2 is hier altijd > Getal1
Dim Opslag As Integer
Dim Uitkomst As String
Opslag = 0
Uitkomst = ""
For i = 1 To Len(Getal2)
If i <= Len(Getal1) Then
Opslag = Opslag + CInt(Left(Right(Getal1, i), 1)) + _
CInt(Left(Right(Getal2, i), 1))
Else
Opslag = Opslag + CInt(Left(Right(Getal2, i), 1))
End If
If Opslag < 10 Then
Uitkomst = Uitkomst & Opslag
Opslag = 0
Else
Uitkomst = Uitkomst & Opslag Mod 10
Opslag = (Opslag - (Opslag Mod 10)) / 10
End If
If i = Len(Getal2) And Opslag > 0 Then
'Bak er een eind aan
Uitkomst = Uitkomst & StrReverse(CStr(Opslag))
End If
Next
Telop = StrReverse(Uitkomst)
End Function
Private Sub Form_Load()
Running = True
Dim Eerste As String
Dim Tweede As String
Dim Swap As String
Dim Counter As String
Eerste = 1
Tweede = 2
Open App.Path & "\fibonacci.txt" For Output As #1
Print #1, "F1" & Chr(9) & Chr(9) & "=1"
Print #1, "F2" & Chr(9) & Chr(9) & "=1"
Counter = 3
Me.Show
Do
Swap = Eerste
DoEvents
Eerste = Tweede
DoEvents
Tweede = Telop(Swap, Tweede)
DoEvents
Print #1, "F"; Counter & Chr(9) & Chr(9) & "=" & Tweede
DoEvents
Counter = Telop("1", Counter)
Fibonacci.Caption = Counter & Chr(9) & Chr(9) & "Calculate fibonacci's with strings!"
Loop While Running
Close #1
End Sub
Private Sub Form_Unload(Cancel As Integer)
Running = False
End Sub
-
Oct 9th, 2000, 02:16 PM
#4
Frenzied Member
What the h*ll are fibinootchi numbers?
Jop - validweb.nl
Alcohol doesn't solve any problems, but then again, neither does milk.
-
Oct 9th, 2000, 02:24 PM
#5
Fanatic Member
Yeah, who is fibinootchi anyway? Is he related to Fibonacci?
-
Oct 10th, 2000, 12:23 AM
#6
Fanatic Member
I have never heard of fibonootchi, but I think he means fibonacci.
-
Oct 10th, 2000, 08:41 AM
#7
Fanatic Member
Did the replies help you?
-
Oct 10th, 2000, 08:53 AM
#8
Thread Starter
New Member
Originally posted by oetje
Did the replies help you?
Yes! the replies helped, even made me giggle.
-
Oct 10th, 2000, 08:54 AM
#9
Thread Starter
New Member
Originally posted by coretta
Originally posted by oetje
Did the replies help you?
Yes! the replies helped, even made me giggle.
-
Oct 10th, 2000, 09:03 AM
#10
Frenzied Member
But who/what is fibonacci ?
Jop - validweb.nl
Alcohol doesn't solve any problems, but then again, neither does milk.
-
Oct 10th, 2000, 09:38 AM
#11
Fanatic Member
Jop this site tells things about Fibonacci:http://www-groups.dcs.st-and.ac.uk/~...Fibonacci.html
Hey, I just found a site that has a vb program that can draw pictures of fibonacci numbers.http://www.moonstar.com/~nedmay/chromat/fibonaci.htm
-
Oct 10th, 2000, 09:44 AM
#12
Thread Starter
New Member
[QUOTE]Originally posted by oetje
Jop this site tells things about Fibonacci:http://www-groups.dcs.st-and.ac.uk/~...Fibonacci.html
Hey, I just found a site that has a vb program that can draw pictures of fibonacci numbers.http://www.moonstar.com/~nedmay/chromat/fibonaci.htm
[/QUOTE cool website! how did you ever find the site? thank!It explains more about fibonacci.
-
Oct 10th, 2000, 09:45 AM
#13
Thread Starter
New Member
[QUOTE]Originally posted by coretta
-
Oct 10th, 2000, 09:46 AM
#14
Thread Starter
New Member
[QUOTE]Originally posted by coretta
Originally posted by coretta
-
Oct 10th, 2000, 09:47 AM
#15
Thread Starter
New Member
[QUOTE]Originally posted by coretta
Originally posted by coretta
Originally posted by coretta
-
Oct 10th, 2000, 09:47 AM
#16
Fanatic Member
Coretta, I just typed "fibonacci" into Altavista...
-
Oct 10th, 2000, 09:56 AM
#17
Thread Starter
New Member
Originally posted by oetje
Coretta, I just typed "fibonacci" into Altavista...
Thank you for showing me the way. I have to get back to work now! Chat with you later.
-
Oct 10th, 2000, 09:58 AM
#18
Frenzied Member
Coretta, I'm sorry but what are you doing?
Oetje, thanx for the sites!
Jop - validweb.nl
Alcohol doesn't solve any problems, but then again, neither does milk.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|