program ColinFibonacci;
procedure drawwindow; {This procedure regulates the draw window size.}
var
textrect: rect;
begin
setrect(textrect, 10, 30, 500, 480);
settextrect(textrect);
showtext;
end;
function Fibmaker (anynum: integer): longint;
begin
if (anynum = 1) or (anynum = 2) then
Fibmaker := 1
else
Fibmaker := Fibmaker(anynum - 1) + Fibmaker(anynum - 2);
end;
procedure Welcome;
var
i: integer;
begin
writeln('Hello, and welcome to Colin''s Fibonacci number generating program. In this');
writeln('program, you can display any term of the sequence of Fibonacci Numbers, and');
writeln('all the Fibonacci numbers that lead up to it. Here''s an example : ');
writeln('Your Input: 5');
for i := 1 to 5 do
writeln(Fibmaker(i) : 1);
writeln('Get the picture? Good.');
end;
procedure GetInfo;
var
i: integer;
x: integer;
begin
writeln('How many Fibonacci numbers would you like to see? {A natural number please}');
repeat
readln(i);
if i < 0 then
writeln('For the love of God, enter a POSITIVE INTEGER!');
until i > 0;
for x := 1 to i do
writeln(Fibmaker(x) : 1);
end;
var
Again: char;
GoodChoice: Boolean;
begin
drawwindow;
welcome;
repeat
GetInfo;
GoodChoice := True;
writeln('Would you like to get another sequence of Fibonacci numbers? (Y/N)');
repeat
if GoodChoice = false then
writeln('Let''s stop being silly. Now enter either Y, y, N or n.');
readln(Again);
if Again in ['Y', 'y', 'N', 'n'] then
GoodChoice := True
else
GoodChoice := false;
until GoodChoice;
until Again in ['n', 'N'];
writeln('Thanks for using this program, if you have any questions or comments,');
writeln('then e-mail Colin at ColinCool@hotmail.com. Press Return to quit.');
readln;
end.