Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "stdafx.h"
- #include <iostream>
- using namespace std;
- double factors(int a, int b);
- int main()
- {
- int x;
- int y = 1;
- cout << "Enter an integer" << endl;
- cin >> x;
- factors(x,y);
- cout << endl;
- system("pause");
- return 0;
- }
- double factors(int a, int b) {
- while(b <= a) { //while a is lesser than or equal to b
- b/a; // divide b by a
- if (a % b == 0){ //if the remainder is 0
- cout << b << " "; // print b
- } //add 1 to a
- b++;
- } // run again
- return b;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement