I have written a code in PLSQL.
Where in I need to Check if sum of cubes of digits = to number itself.
I have tried abiding by the algorithm,still there are some errors.Please help.
I’m new to PLSQL.
Following is my code:
set serveroutput on;
Declare
I number(4);
Sum number(4):=0;
C number(15):=10;
Begin
for I in 1..999
loop
-- dbms_output.put_line(I);
Sum:=power(mod(I,C),3);
while mod(I,C)
loop
Sum:=power(mod(mod(I,C),C),3);
C:=C*10;
end loop;
if Sum=I then
dbms_output.put_line(I);
end if;
end loop;
End;
/
sumis a key word in plsql, you should not be using that as a variable name.Here is the solution for your problem:
The solution works for any INTEGER, i, which is NUMBER(38).