Computer Science, asked by mhdsajid, 4 months ago

#include <iostream>
int main() {
int n;
std::cout<<"Enter the number"<<std::endl;
std::cin>>n;
// -------------------- code ---------------------
int sum = 0;
for (int i=1; i<n/2; i++){
if (n%i == 0){
sum += i;
}
}
std::cout<<"Sum of factors of "<<n<<": "<<sum<<std::endl;
}
there's some miskates in the code help and correct it to run the code?​

Answers

Answered by mhshahid420
0

#include <iostream>

int main() {

int n;

std::cout<<"Enter the number"<<std::endl;

std::cin>>n;

// -------------------- code ---------------------

int sum = 0;

for (int i=1; i<n/2; i++){

if (n%i == 0){

sum += i;

}

}

std::cout<<"Sum of factors of "<<n<<": "<<sum<<std::endl;

}

Similar questions