CPP
cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include <iostream>
using namespace std;
/* The factors of a number are all those numbers that can divide evenly into the number with no remainder. */
int main()
{
//sample number
int n = 128;
cout << "Factors of " << n << " are: " << endl;
for (int i = 1; i <= n; ++i)
{
if (n%i == 0)
cout << i << endl;
}
return 0;
}
Enter to Rename, Shift+Enter to Preview
OUTPUT
Ejecutar