代码拉取完成,页面将自动刷新
//We include de I/O library
#include <iostream>
/* We include the stdenteredNumeramespace so we don't have to write std::
Everytime we want to use "cout" or "cin" */
using namespace std;
int main()
{
// We declare our variables
int enteredNumer, i, factorization;
// Ask for a number
cout << "Enter a number of your choice (positive and integeer): ";
// Assing the entered value to the "enteredNumer" variable
cin >> enteredNumer;
cout << "These are the factors for " << enteredNumer << ": " << endl;
factorization = enteredNumer;
// Every number has 1 as it's factor, so we'll say this right away
cout << 1 << endl;
// Check the factors (starting with 2, until the number is reached)
for(i = 2; i <= enteredNumer; ++i)
{
// If the divided number has 0 as the division reminder, it'll be a factor
while (factorization % i == 0){
// Print this number everytime
cout << i << endl;
// As it is a factor, let's divide by it to find the next one!
factorization = factorization / i;
};
}
return 0;
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。