Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

3
  • 1
    \$\begingroup\$ You are using variable p in a single place, so no need for it. You can move the initialization of variable a into the for to spare its separate ;: for((a=$1;a>0;a/=10));do s=$[s+(a%10)**${#1}];done;echo $[s==$1]. \$\endgroup\$ Commented Nov 15, 2013 at 11:08
  • 1
    \$\begingroup\$ By moving the evaluation into the for one more character can be shortened: for((a=$1;a>0;s+=(a%10)**${#1},a/=10));do :; done;echo $[s==$1]. \$\endgroup\$ Commented Nov 15, 2013 at 11:16
  • \$\begingroup\$ Oh, curious! I tried something like that, but it didn't work. Curious what went wrong. \$\endgroup\$ Commented Nov 16, 2013 at 1:53