#include <stdio.h>
#include <math.h>
int i;
double result = 0;
int terms;
int term;
double stage1;
double stage2;
double zeta(int terms){
for (i=0; i != terms; i++){
result += 1 / pow(i, 2);
}
return result;
}
double pi(int term){
stage1 = zeta(term) * 6;
stage2 = sqrt(stage1);
return stage2;
}
int main(){
printf("the terms?:");
scanf("%d", &term);
pi(term);
printf("%f", pi(term));
}
i wrote this code that uses the zeta function to calculate pi but it keeps outputting infinity no matter how many terms i tried python and it works normally there any ideas on how to fix it?
i looked into it and i think it might be the math library because it does output infinity i was at least expecting an approximation of pi but it did not even output that it just outputted infinity