Ich wollte einen simplen Fibonacci-Rechner programmieren. Hier ist der Quelltext:
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47:
| unit Fibonacci;
interface
uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ExtCtrls, StdCtrls;
type TForm1 = class(TForm) Button1: TButton; Edit1: TEdit; Panel3: TPanel; Label1: TLabel; procedure Button1Click(Sender: TObject);
private public end;
var Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject); var Ausgabe: String; zw1, zw2, F, n, i: Longword; begin n := strtoint (Edit1.Text); i := 0; zw1 := 1; zw2 := 1; repeat inc (i); F := zw2; zw2 := zw1 + zw2; zw1 := F; until (i = n); Ausgabe := inttostr(zw2); Label1.Caption := Ausgabe; end; end. |
Das Problem ist, dass ab der 74. immer kleiner wird.
Moderiert von
Christian S.: Code- durch Delphi-Tags ersetzt