Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int querSum(int eingabe);
- int harshad(int eingabe);
- int main()
- {
- int eingabe =0;
- int harsh;
- cin >> eingabe;
- harsh = harshad(eingabe);
- cout << harsh << endl;
- return 0;
- }
- int querSum(int eingabe)
- {
- int querSum = 0;
- while(eingabe > 0)
- {
- querSum += eingabe % 10;
- eingabe /= 10;
- }
- return querSum;
- }
- int harshad(int eingabe)
- {
- //int searchedharshad = querSum(eingabe);
- while (eingabe % querSum(eingabe) != 0)
- {
- harshad(++eingabe);
- }
- return eingabe;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement