0
\$\begingroup\$

Challenge

Your goal is, given two positive integer numbers a and b, to calculate (and output) a ^ b without using either multiplication, division and the power itself (not directly, at least). And, of course, built-in exponentiation functions.

Scoring

This is code-golf, so the shorter, the better.

Test cases

Input => Output
2, 3 => 8
5, 5 => 3125
100, 4 => 100000000
17, 9 => 118587876497
0, 1 => 0
3921, 0 => 1
\$\endgroup\$
3
  • \$\begingroup\$ I assume by ^ you mean exponentiation? In some languages ^ has a different meaning. \$\endgroup\$
    – Alex A.
    Commented Apr 30, 2016 at 19:35
  • \$\begingroup\$ Welcome to Programming Puzzles & Code Golf. This is currently underspecified, since the symbols ^, *, / and ^ can have a completely different meaning in my language of choice than you intended. Please note that do X without Y challenges are rather hard to write, because of loopholes, ambiguities and similarity to other restricted-source challenges. \$\endgroup\$
    – Dennis
    Commented Apr 30, 2016 at 19:42
  • \$\begingroup\$ I think it's a possible duplicate of Exponentiation of natural numbers using only primitive integer operations (which might not really be a duplicate, although it's currently marked as such) \$\endgroup\$ Commented Apr 30, 2016 at 19:47

1 Answer 1

1
\$\begingroup\$

k (19 bytes)

This is slow and uses lots of memory:

{#,//(x#,:)/[y;0b]}

The /s are not division, it's the converge operator.

\$\endgroup\$

Not the answer you're looking for? Browse other questions tagged or ask your own question.