write a program in C++ that takes a number from user and prints the first three multiples and first three factors of that number
#include <iostream>
using namespace std;
int main()
{
int n, i;
cout << "Enter a positive integer: ";
cin >> n;
cout << "Factors of " << n << " are: ";
for(i = 1; i <= n; i++)
{
if(n % i == 0)
cout << i << " ";
}
return 0;
}
Comments
Leave a comment