Home > Back-end >  Bosses look
Bosses look

Time:09-25

Use of convicted prime function, complete all prime Numbers between 100 to 200 the average output,
# include
# include
Int main () {
Float s=1.0, t=1.0, n=1.0; While (fabs (t) & gt; 1-5 e)
{t=pow (1, n + 1) * 1.0/(n * n + 1);
S=s + t;
N++; } printf (" % f \ n ", s);
return 0;
}

CodePudding user response:

#include

Int isPrime (int x) {
If (x<2) return 0;
For (int I=2; iIf I==0) (x % return 0;
}
return 1;
}

Int main ()
{
Float sum=0.0;
int count=0;
For (int I=100; i<=200; I++) {
{if (isPrime (I))
sum +=i;
count++;
}
}
Printf (" primes average of between 100 ~ 200: % 2 f ", sum/count);
return 0;
}

For your reference
  • Related