Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Code correction - PL/SQL

Albert ChaoJul 28 2021 — edited Jul 28 2021

Can someone please correct the code below. The code is to find perfect numbers between 1 to 100

set serveroutput on;
DECLARE
sum NUMBER;
p NUMBER;
BEGIN
dbms_output.put_line('Perfect numbers between 1 and 100 are :');
p := 1;
FOR i IN i..100

LOOP
while(p<=(i/2))
end loop;

if(mod(i,p)=0) then
sum := sum +p;
p := p+1;
end if;
end loop;
if(sum = i)
dbms_output.put_line ( i|| ' ' ) ;
SUM := 0 ;
END ;

Comments

Post Details

Added on Jul 28 2021
6 comments
600 views