I have made a program that specifies whether a speech is a prime or not:
and I need help to add some comments , can somebody help me please?
Code:program Project5; {$APPTYPE CONSOLE} uses SysUtils; var stop: string; number : integer; test : boolean; procedure faktorer; var b,summa : integer; begin b:=1; sum:=number; repeat b:=b+1; if sum mod b =0 then begin sum:=sum div b; if sum=1 then write (b,' = ',number) else write (b, ' * ') ; b:=1; end; until sum=1; end; procedure count; // var i,sum: integer; begin i:=1; repeat i:=i+1; sum:=tal mod i; if sum = 0 then test:=false; until (i = tal-1) or (test = false); if test=false then writeln('this was no prime') else writeln('prime '); end; begin try repeat test:=true; writeln(inputting a number'); readln(number); if tal <=2 then writeln('prime ') else begin; count; end; if test=false then factors; writeln; writeln(do you want to test more?(y/n)'); readln(stop); until stop='n'; except on E:Exception do begin Writeln(E.Classname, ': ', E.Message); readln; end; end; end.
Last edited by WingedPanther; 02-05-2009 at 04:51 PM. Reason: add code tags (the # button)
Well, start with indicating what each function is for, and what the program as a whole is supposed to do.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks