Skip to main content
Code Golf

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*

Work out \$x^y\$ using only addition and subtraction [duplicate]

The challenge is to implement a function or program that takes two numbers, \$x\$ and \$y\$ and return the result of \$x^y\$.

The program cannot use any other mathematical operation other than \$+\$ or \$-\$, so no multiplication or division. Functions built into languages are also not allowed.

The code in the least amount of bytes wins.

Answer*

Draft saved
Draft discarded
Cancel
4
  • \$\begingroup\$ I was groping toward this solution in a "traditional" mode; however, for some reason, I can never get APL to produce output on TIO - what might I be doing wrong? The test case I was trying with was +/4⍴+/3⍴3, to see if I was on the right track for 3^4. \$\endgroup\$ Commented Jan 16, 2019 at 14:12
  • \$\begingroup\$ @JeffZeitlin If you put code in TIO's Code field, you must use ⎕← to output. \$\endgroup\$ Commented Jan 16, 2019 at 14:16
  • \$\begingroup\$ Thanks. I don't know a facepalm emoticon/emoji, but consider it included here... \$\endgroup\$ Commented Jan 16, 2019 at 14:29
  • \$\begingroup\$ @JeffZeitlin 🤦︎ \$\endgroup\$ Commented Jan 16, 2019 at 14:34

AltStyle によって変換されたページ (->オリジナル) /