Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<math.h>
- int main()
- {
- int m,n,i,j,c,sum,cs=1;
- printf("Enter Limit: ");
- scanf("%d",&n);
- while(1)
- {
- printf("Case %d\n",cs);
- c=0,sum=0;
- for(j=2 ; j<=n ; j++)
- {
- for(i=2 ; i<=sqrt(j) ; i++)
- {
- if(j%i==0)
- break;
- }
- if (i>sqrt(j))
- {
- printf("%d ",j);
- c++, sum=sum+j;
- }
- }
- printf("\nCount: %d\nSum: %d\n",c,sum);
- printf("Enter Limit: ");
- scanf("%d",&m);
- if(m<n)
- break;
- else
- n=m;
- cs++;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement