Aniket_Goku

armstrong

Sep 12th, 2020
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PL/SQL 0.55 KB | None | 0 0
  1. /*ARMSTRONG */
  2. DECLARE
  3.  
  4. no1 NUMBER:=153;
  5.  
  6. no2 NUMBER;
  7.  
  8. mal NUMBER;
  9.  
  10. sam NUMBER;
  11.  
  12. ans NUMBER;
  13.  
  14. l NUMBER;
  15.  
  16.  
  17.  
  18. BEGIN
  19.  
  20.  
  21.  
  22. mal:=1;
  23. sam:=0;
  24.  
  25.  
  26.  
  27. l:=LENGTH(TO_CHAR(no1));
  28.  
  29. no2:=no1;
  30.  
  31.    
  32. WHILE(no2>0) LOOP
  33.        
  34.        
  35.    
  36.      ans:=MOD(no2,10);
  37.  
  38.  
  39.     mal:=POWER(ans,l);
  40.    
  41.      sam:=sam+mal;
  42.  
  43.       no2:=FLOOR(no2/10);
  44.  
  45. END LOOP;  
  46.  IF(sam=no1) THEN
  47.  
  48.       DBMS_OUTPUT.put_line( no1 ||' IS armstrong number');
  49. ELSE
  50.               DBMS_OUTPUT.put_line( no1 ||' IS  NOT  armstrong number');
  51.  
  52.  
  53.     END IF;
  54.  
  55.  
  56.  
  57. END;
Add Comment
Please, Sign In to add comment