Armstrong number is a number that is equal to the sum of cubes of its digits. For example 0, 1, 153, 370, 371 and 407 are the Armstrong numbers.
PL/SQL Program for Armstrong Number
declare num1 number:=371; sum1 number:=0; rem number; len number; num2 number; begin num2:=num1; len:=length(to_char(num1)); while num1>0 loop rem:=mod(num1,10); sum1:=sum1+power(rem,len); num1:=trunc(num1/10); end loop; if num2=sum1 then dbms_output.put_line('armstrong number'); else dbms_output.put_line('not armstrong number'); end if; end;
Output:-
armstrong number