repeat_sum in C