#include <iostream>
int main() {
int n;
std::cout << "Nhap so tu nhien n: ";
std::cin >> n;
int sum = 0;
for (int i = 1; i <= n; i++) {
if (i % 3 == 0) {
sum += i;
}
}
std::cout << "Tong cac so tu nhien nho hon hoac bang " << n << " ma chia het cho 3 la: " << sum << std::endl;
return 0;
}
```c++
#include <iostream>
using namespace std;
int main() {
int n, sum = 0;
cout << "Nhap so nguyen duong n: ";
cin >> n;
for (int i = 1; i <= n; i++) {
if (i % 3 == 0) {
sum += i;
}
}
cout << "Tong cac so tu nhien nho hon hoac bang " << n << " ma chia het cho 3 la: " << sum;
return 0;
}
```