View Code of Problem 27

#include <stdio.h>
#include <math.h>
int sheep(int i){
	int i,j,k;
	k= sqrt(i);
	for(j=2; j < k; j++)
	{
		if(i%j == 0)
			return 0;
	}
	return i;
}

int main(){
	int a,b,i,sum=0;
	while(scanf("%d%d",&a,&b) != EOF)
	{
		for(i=a+1;i < b; i++)
		sum +=sheep(i);
		printf("%d\n",sum);
	}
	
	return 0;
}
/*
Main.c: In function 'sheep':
Main.c:4:6: error: 'i' redeclared as different kind of symbol
  int i,j,k;
      ^
Main.c:3:15: note: previous definition of 'i' was here
 int sheep(int i){
               ^
*/

Double click to view unformatted code.


Back to problem 27