Íàéòè ïåðâîå èç ÷èñåë Ôèáîíà÷÷è, áîëüøèõ m, (m=1000).

 

 

Var m : Longint;

 

Function FIB(B:Integer):Longint;

Var I,Temp,I1,I2 : Longint;

Begin

     I1 := 0;

     I2 := 1;

     For I := 1 To B Do Begin

         Temp := I1 + I2;

         I1 := I2;

         I2 := Temp;

     End;

     Fib := Temp;

End;

 

Function FIB2(B:Longint):Longint;

Var I,Temp,I1,I2 : Longint;

Begin

     I1 := 0;

     I2 := 1;

     Temp := 1;

     While Temp <= B Do Begin

         Temp := I1 + I2;

         I1 := I2;

         I2 := Temp;

     End;

     Fib2 := Temp;

End;

 

Begin

     Write('Ââåäèòå çíà÷åíèå  m: ');

     ReadLn(m);

     WriteLn(m:4,' ',FIB2(m):10);

Readkey;

End.