正攻法で書くとこんな感じか。
/* my_cbrt.c */ #include <stdio.h> #include <stdlib.h> #include <math.h> #define CONV_REPEAT 30 double my_cbrt(int N) { double x = N; int i; for(i = 0; i < CONV_REPEAT; i++) { x = sqrt(sqrt((double)N * x)); } return x; } int main(int argc, char **argv) { int n = atoi(argv[1]); /* コマンドライン引数から任意の数を得る流れは手抜き */ double x = my_cbrt(n); printf("cbrt(%d) = %f (^3 = %f)\n", n, x, x * x * x); return EXIT_SUCCESS; }