Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

Fibbing

program Fibbing;

var
  places, count, total: integer;
  sequence: array of integer;

procedure setSequence ();
begin
  setlength(sequence, places);
  sequence[0] := 1;
  sequence[1] := 1;
  for count := 2 to places - 1 do
      sequence[count] := sequence[count - 1] + sequence[count - 2];
end;

begin
  writeln('How many places?');
  readln(places);
  setSequence();
  write('Sequence:');
  for count := 0 to places - 1 do
    write(' ', sequence[count]);
  writeln;
  write('Reverse:');
  for count := 1 to places do
    write(' ', sequence[places - count]);
  writeln;
  total := 0;
  for count := 0 to places - 1 do
    total += sequence[count];
  writeln('Total: ', total);
  readln;
end.

Advertisements
Loading...

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.