#include <stdio.h>
int main()
{ int num, i=0, multiples=0, limit;
printf("Put a number.\n");
scanf("%d", &num);
printf("Between 1 and\n");
scanf("%d", &limit);
while (i<=limit)
{ i++;
if(i%num==0)
{
multiples+=i;
}
;
}
printf("Sum of all multiples of %d between 1 and %d is %d", num, limit, multiples);
return 0;
}
int main()
{ int num, i=0, multiples=0, limit;
printf("Put a number.\n");
scanf("%d", &num);
printf("Between 1 and\n");
scanf("%d", &limit);
while (i<=limit)
{ i++;
if(i%num==0)
{
multiples+=i;
}
;
}
printf("Sum of all multiples of %d between 1 and %d is %d", num, limit, multiples);
return 0;
}
댓글
댓글 쓰기