Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Treebeard's String-Math
#10
@Jack - Your first version reminds me of the Fibonacci sequence:

Code: (Select All)
'Fibonaccizahl - 29. Juli 2022
'https://de.wikipedia.org/wiki/Fibonacci-Folge
'https://en.wikipedia.org/wiki/Fibonacci_number

Option _Explicit

Dim x, y As Long
Dim i, n As Integer

x = 1: y = 1: i = 1
Cls
Locate 3, 3
Print "Berechnet iterativ die Fibonaccizahl."

Locate 5, 3
Input "Geben Sie eine Zahl ein: ", n

Locate 7, 3
If n > 33 Then
  Print "Nur Eingaben bis 33!"
  GoTo Ende
End If

If n = 0 Then
  Print Using "Die Fibonaccizahl von # ist: #"; n, 1
  GoTo Ende
ElseIf n = 1 Then
  Print Using "Die Fibonaccizahl von # ist: #"; n, 1
  GoTo Ende
ElseIf n = 2 Then
  Print Using "Die Fibonaccizahl von # ist: 1 1 #"; n, n
  GoTo Ende
End If

If n > 2 Then
  Print "0 1 1 ";
  While i < n
    x = x + y: y = x - y: i = i + 1
    Print " "; x;
  Wend
End If

Print: Print
Locate , 3
Print Using "Die Fibonaccizahl von ## ist: ###,#####"; n, x

Ende:
End
Reply


Messages In This Thread
Treebeard's String-Math - by Jack - 07-27-2022, 11:52 PM
RE: Treebeard's String-Math - by Pete - 07-28-2022, 02:00 AM
RE: Treebeard's String-Math - by Jack - 07-28-2022, 02:12 AM
RE: Treebeard's String-Math - by Pete - 07-28-2022, 06:17 AM
RE: Treebeard's String-Math - by Jack - 07-28-2022, 10:43 AM
RE: Treebeard's String-Math - by James D Jarvis - 07-28-2022, 03:09 PM
RE: Treebeard's String-Math - by Pete - 07-28-2022, 04:02 PM
RE: Treebeard's String-Math - by James D Jarvis - 07-28-2022, 05:23 PM
RE: Treebeard's String-Math - by Pete - 07-28-2022, 04:55 PM
RE: Treebeard's String-Math - by Kernelpanic - 07-29-2022, 07:06 PM
RE: Treebeard's String-Math - by Jack - 07-29-2022, 08:45 PM
RE: Treebeard's String-Math - by Kernelpanic - 07-29-2022, 09:13 PM
RE: Treebeard's String-Math - by Jack - 07-29-2022, 09:36 PM
RE: Treebeard's String-Math - by Jack - 07-29-2022, 10:33 PM
RE: Treebeard's String-Math - by Pete - 07-29-2022, 11:18 PM
RE: Treebeard's String-Math - by Jack - 07-30-2022, 12:13 AM
RE: Treebeard's String-Math - by Pete - 07-30-2022, 12:30 AM
RE: Treebeard's String-Math - by Jack - 07-30-2022, 12:37 AM
RE: Treebeard's String-Math - by Pete - 07-30-2022, 12:56 AM
RE: Treebeard's String-Math - by Jack - 07-30-2022, 01:05 AM
RE: Treebeard's String-Math - by Pete - 07-30-2022, 02:44 AM
RE: Treebeard's String-Math - by Jack - 07-31-2022, 12:34 PM
RE: Treebeard's String-Math - by bplus - 07-31-2022, 03:03 PM
RE: Treebeard's String-Math - by Jack - 07-31-2022, 04:41 PM
RE: Treebeard's String-Math - by Jack - 08-08-2022, 06:12 PM
RE: Treebeard's String-Math - by bplus - 08-08-2022, 07:23 PM
RE: Treebeard's String-Math - by Jack - 08-08-2022, 09:04 PM



Users browsing this thread: 1 Guest(s)