Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- int main() {
- int num,i,j,c, sum = 0;
- printf("please enter the number = ");
- scanf("%d",&num);
- for (j=1;j<=num;j++){
- for (i=1,c=0;i<=j;i++){
- if (j%i==0){
- c++;
- }
- }
- if (c==2){
- printf("%d\n",j);
- sum = sum + j;
- }
- }
- printf("The sum = %d", sum);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement