برنامه ی سی پلاس پلاس برای نمایش فاکتورها یا مقسوم علیه ها ی یک عدد
جمعه, ۱۶ مهر ۱۳۹۵، ۰۷:۰۹ ب.ظ
gameover.blog.ir
/* C++ to find and display all the factors of a number entered by an user.. */
#include <iostream>
using namespace std;
int main()
{
int n,i;
cout << "Enter a positive integer: ";
cin >> n;
cout << "Factors of " << n << " are: " << endl;
for(i=1;i<=n;++i)
{
if(n%i==0)
cout << i << endl;
}
return 0;
}
Output
Enter a positive integer: 60 Factors of 60 are: 1 2 3 4 5 6 12 15 20 30 60
۹۵/۰۷/۱۶