Q. How do I write Bash Script to find Armstrong number
Ans:
#!/bin/bash #Script to find armstrong number till 500, you can change it i=1 while((i<=500)) do c=$i d=$i b=0 a=0 #checking each number while((c>0)) do #separating each digit a=$((c%10)) #finding cube of each digit and adding them b=$((b + a*a*a)) c=$((c/10)) done if((b==d)); then echo "$i" fi i=$((i+1)) done
Output
Enjoy :)
If You Liked This Post Please Take a Time To Share This Post
Hi, thanks for your great information! Well, it really seems so great. http://www.lowhosting.com/networksolutions-review/
ReplyDeletesend boobs
DeleteYour effort in writing this is really praiseworthy, thank you so much. Read this article for complete details. The CPS Test is one of the most popular online tests.
ReplyDelete