Here you will get pl/sql program for armstrong number.
A number is said to be an armstrong number if sum of its digits raised to the power n is equal to number itself, where n is total digits in number.
For example 407 is armstrong number as 43 + 03 + 73 = 64 + 0 + 343 = 407.
PL/SQL Program for Armstrong Number
declare
n number:=407;
s number:=0;
r number;
len number;
m number;
begin
m:=n;
len:=length(to_char(n));
while n>0
loop
r:=mod(n,10);
s:=s+power(r,len);
n:=trunc(n/10);
end loop;
if m=s
then
dbms_output.put_line('armstrong number');
else
dbms_output.put_line('not armstrong number');
end if;
end;
/
Output
armstrong number
The post PL/SQL Program for Armstrong Number appeared first on The Crazy Programmer.
from The Crazy Programmer http://www.thecrazyprogrammer.com/2017/08/plsql-program-armstrong-number.html
Comments
Post a Comment