Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int main() {
- int n;
- cout << "n = ";
- cin >> n;
- // Finding and printing divisors using sqrt function
- for (int i = 1; i <= sqrt(n); i++) {
- if (n % i == 0) {
- cout << i << " ";
- if (i != sqrt(n)) {
- cout << n / i << " ";
- }
- }
- }
- // Finding and printing divisors using for loop
- /*
- cout << "\nMetoda lui Toni: " << endl;
- for (int i = 1; i <= n; i++) {
- if (n % i == 0) {
- cout << i << " ";
- }
- }
- */
- }
Advertisement
Add Comment
Please, Sign In to add comment