Autor Beitrag
Black200607
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 50

Win XP
Pascal(Free Pascal/Lazarus), Java, Php, Python
BeitragVerfasst: Do 17.05.07 15:27 
Ich wollte einen simplen Fibonacci-Rechner programmieren. Hier ist der Quelltext:

ausblenden volle Höhe Delphi-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
    { Private-Deklarationen }
  public
    { Public-Deklarationen }
  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 user profile iconChristian S.: Code- durch Delphi-Tags ersetzt
n00ki3
Hält's aus hier
Beiträge: 12



BeitragVerfasst: Do 17.05.07 15:36 
Ich vermute mal ,dass die 74te Fibonacci zah l aus dem Zahlenbereich des longwords fällt .

Versuchs mal mit Int64 :)
Black200607 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 50

Win XP
Pascal(Free Pascal/Lazarus), Java, Php, Python
BeitragVerfasst: Do 17.05.07 15:39 
Klappt, Dankeschön