Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- using namespace std;
- ofstream fout("trei.out");
- int getSum(int x) {
- int sum = 0;
- while (x) {
- sum += x % 10;
- x /= 10;
- }
- return sum;
- }
- int main() {
- for (int i = 100; i < 1000; i++) {
- if (i % getSum(i) == 0) {
- fout << i << ' ';
- }
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment