fork download
  1. #include <stdio.h>
  2.  
  3. int main() {
  4. int i = 1;
  5. int sum = 0;
  6.  
  7. // 1から100までの数値を調べる
  8. while (i <= 100) {
  9. // 3の倍数でもなく、5の倍数でもない場合かつ1の位が6以上の場合
  10. if (i % 3 != 0 && i % 5 != 0 && i % 10 >= 6) {
  11. sum += i; // 和に加える
  12. }
  13. i++; // 次の数値へ
  14. }
  15.  
  16. printf("1から100のうち、条件を満たす数字の和: %d\n", sum);
  17.  
  18. return 0;
  19. }
Success #stdin #stdout 0s 5280KB
stdin
8 20
stdout
1から100のうち、条件を満たす数字の和: 1365