Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Var
- a, b, n: Integer;
- IsCorrect: Boolean;
- Begin
- a := 1;
- b := 1;
- Writeln('The program will calculate the n-th term of the Fibonacci series.');
- Write('Enter the Fibonacci series member number: ');
- Repeat
- Try
- IsCorrect := True;
- Read(n);
- If (n < 0) Or (n = 0) Then
- Begin
- IsCorrect := False;
- Write('A negative value or zero was entered. Enter a valid value: ');
- End;
- Except
- Begin
- Write('Symbols have been entered. Enter the number: ');
- IsCorrect := False;
- End;
- End;
- Until IsCorrect;
- For Var i := 2 To n - 1 Do
- Begin
- b := a + b;
- a := b - a;
- End;
- Write(b);
- End.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement