Assembly x86x86 machine code (Linux), 18 bytes
31 c0 ff c0 31 db 39 df 74 07 0f af c7 ff c3 eb f5 c3
It expects a C declaration as follows extern int XpowX(int)
.
Disassembled
XpowX:
# edi : input register
# ebx : counter
# eax : result register
xor %eax, %eax # result = 0
inc %eax # result += 1
xor %ebx, %ebx # counter = 0
loop:
cmp %ebx, %edi # if (counter == input)
je done # return result
imul %edi, %eax # result *= input
inc %ebx # counter += 1
jmp loop
done:
ret