Вы находитесь на странице: 1из 2

#include

#include
#include
#include

<stdio.h>
<conio.h>
<string.h>
<math.h>

int main(){
//oppgave3();
//oppgave4();
oppgave4Del2();
}
int teller1;
double teller2;
float teller3=1;
float teller4=0;
float brok;
float brokSum=0;
oppgave3(){
int teller1;
float teller3=1;
float brok;
float brokSum=0;
for(teller1=0; teller1<=1000; teller1++){
for(teller2=1; teller2<=teller1; teller2++){
teller3=teller3*teller2;
}
//printf("%f",teller3);
brok=1/teller3;
teller3=1;
//printf("\n%f",brok);
brokSum=brokSum+brok;
}
printf("\n%.15f",brokSum);
system("pause");
}
oppgave4(){
double
double
double
double

teller1;
nevner=1;
brok;
sumBrok=0;

int lock=1;
double del;
double sum;
for(teller1=0; teller1<10000000000; teller1++){ //dette gir 12 gjeldede
siffer
nevner=nevner+2;
brok=(1/nevner);
if(lock==1){
sumBrok=sumBrok-brok;
lock=0;
}

else{
sumBrok=sumBrok+brok;
lock=1;
}
}
//printf("%d",sumBrok);
del=1+sumBrok;
sum=4*del;
printf("\n%.15f",sum);
}
oppgave4Del2(){
double sum=0;
double teller17=0;
double del=0;
double broken=0;
for(teller17=1; teller17<1000000000; teller17++){
sum=sum +(1/(teller17*teller17));
}
printf("%.15lf",sum);
}