(adsbygoogle = window.adsbygoogle || []).push({ google_ad_client: "ca-pub-2960223314593660", enable_page_level_ads: true }); Python Program to check a given number is an armstrong or not. - TecGlance

Header Ads

Python Program to check a given number is an armstrong or not.

Algorithm::


Step 1: Read a number, num.

Step 2: Assign temp=num.

Step 3: Assign sum=0.

Step 4: Repeat steps 5,6&7 until temp=0 reaches.

Step 5: Compute digit=temp%10.

Step 6: Compute temp=temp/10.

Step 7: Compute sum=sum+(digit**3).

Step 8: If num==sum goto step 9 else goto step 10.

Step 9: Print num is an Armstrong number.

Step 10: Print num is not an Armstrong number.

Step 11: Stop


Flowchart::


No comments

Powered by Blogger.