simple-exponentiation.c (454B)
1 // the goal was to make this as few lines as possible... 2 // that makes this janky af with the additional input variable instead of another definition... 3 #include <stdio.h> 4 #include <stdlib.h> 5 int power(int x, int y, int result){ 6 for(int n = 0; n < y - 1; ++n) 7 result *= x; 8 return result; 9 } 10 int main(int argc, char** argv){ 11 printf("%d ^ %d = %d\n", atoi(argv[1]), atoi(argv[2]), power(atoi(argv[1]), atoi(argv[2]), atoi(argv[1]))); 12 }