Lazarus
Free Pascal => Beginners => Topic started by: sorcar on September 08, 2018, 04:50:21 pm
-
Hello,
I'm new to FPC and Lazarus.
I've been trying to make this work for a while but it just doesn't do anything, can someone please give me an idea of what I am doing wrong?
PROGRAM numerosprimos1 (input, output);
VAR
numero, n, p, base1, potencia, modulo, m: integer;
BEGIN
n:=2;
p:=1;
base1:=0;
readln(numero);
while n<numero do
BEGIN
m:=n;
modulo:=numero MOD m;
if modulo=0 then
BEGIN
base1:=m;
potencia:=p;
m:=m*m;
p:=p+1;
END
else
BEGIN
if base1>0 then
BEGIN
if potencia>1 then
BEGIN
writeln(base1,'^',potencia);
potencia:=1;
base1:=0;
numero:=numero-m;
END
else
BEGIN
writeln(base1);
base1:=0;
numero:=numero-m;
END
END
else
n:=n+1;
END
END
END.
-
I tested your program and
- if I enter prime number, program ends correctly without any output
- if I enter non-prime number, program falls to endless loop, without any output
:)
-
Misisng som ; after END, where there is not an else follwing...
(Actually think you should be getting compiler errors...)
-
No reply from TS, so probably his deadline for this homework assignment has passed.
Bart