declare
n number;
i number;
tot number;
begin
n:=&n;
tot:=0;
for i in 1..n/2
loop
if(n mod i=0) then
tot:= tot+i;
end if;
end loop;
if(n=tot)then
dbms_output.put_line('Perfect no');
else
dbms_output.put_line('Not a Perfect no');
end if;
end;
n number;
i number;
tot number;
begin
n:=&n;
tot:=0;
for i in 1..n/2
loop
if(n mod i=0) then
tot:= tot+i;
end if;
end loop;
if(n=tot)then
dbms_output.put_line('Perfect no');
else
dbms_output.put_line('Not a Perfect no');
end if;
end;
FULL OF ERROR DUDE. WASTEππππ
ReplyDeleteno its working
DeleteThis comment has been removed by the author.
Deletedeclare
Deleten number;
i number;
tot number;
begin
n:= 496;
tot:=0;
for i in 1..n/2
loop
if(n mod i=0) then
tot:= tot+i;
end if;
end loop;
if(n=tot)then
dbms_output.put_line('Perfect no');
else
dbms_output.put_line('Not a Perfect no');
end if;
end;
DECLARE
ReplyDeleten number(3):=8;
num1 number(1):=1;
sumn number(4):=0;
BEGIN
dbms_output.put_line('Check for Perfect Number');
while (num1<n)
loop
if mod(n,num1)=0 then sumn:=sumn+num1;
end if;
num1:=num1+1;
end loop;
if sumn=n then dbms_output.put_line(n||' is Perfect Number');
else dbms_output.put_line(n||' is not Perfect Number');
end if;
end;
Check for the number you want, just put in your value in Line 2.
Delete