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
Delete