fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5. int n;
  6. cin >> n;
  7.  
  8. int i = n; // bắt đầu từ n
  9. while (i >= 0) { // lặp khi i còn >= 0
  10. if (i % 3 == 0 or i % 5 == 0) // nếu chia hết cho 3 hoặc 5
  11. cout << i << " "; // in ra i
  12. i--; // giảm i xuống 1 mỗi vòng
  13. }
  14.  
  15. return 0;
  16. }
Success #stdin #stdout 0.01s 5288KB
stdin
10
stdout
10 9 6 5 3 0