fork download
  1. #include <stdio.h>
  2.  
  3. int main(void) {
  4. int i = 1;
  5. int sum = 0;
  6.  
  7. while (i <= 100) {
  8. // 3の倍数でもなく、5の倍数でもなく、1の位が4以上のものを選ぶ
  9. if (i % 3 != 0 && i % 5 != 0 && (i % 10) >= 4) {
  10. sum += i;
  11. }
  12. i++;
  13. }
  14.  
  15. printf("条件を満たす数の合計は %d です。\n", sum);
  16.  
  17. return 0;
  18. }
  19.  
  20.  
Success #stdin #stdout 0.01s 5316KB
stdin
Standard input is empty
stdout
条件を満たす数の合計は 1693 です。