Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*ARMSTRONG */
- DECLARE
- no1 NUMBER:=153;
- no2 NUMBER;
- mal NUMBER;
- sam NUMBER;
- ans NUMBER;
- l NUMBER;
- BEGIN
- mal:=1;
- sam:=0;
- l:=LENGTH(TO_CHAR(no1));
- no2:=no1;
- WHILE(no2>0) LOOP
- ans:=MOD(no2,10);
- mal:=POWER(ans,l);
- sam:=sam+mal;
- no2:=FLOOR(no2/10);
- END LOOP;
- IF(sam=no1) THEN
- DBMS_OUTPUT.put_line( no1 ||' IS armstrong number');
- ELSE
- DBMS_OUTPUT.put_line( no1 ||' IS NOT armstrong number');
- END IF;
- END;
Add Comment
Please, Sign In to add comment