Answer the question
In order to leave comments, you need to log in
Find the sum and number of divisors of a natural number?
Numeric functions
The number of all natural divisors of a natural number n is denoted by σ0(n). The sum of all natural divisors of a number n is denoted by σ1(n).
Specifications Input
Given natural number n≤109.
Output
Output σ0(n) and σ1(n).
Note
This problem is recommended to be solved by enumeration of all divisors of a number up to n−−√.
Examples
Input
6
Output
4 12
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;
int main()
{
int n,c=0,s=0;
cin >> n;
for (int i = 1; i <= sqrt(n) ; i++)
{
if (n % i == 0 and i != sqrt(n)) {
c += 2;
s += (i + n / i);
}
if (i == sqrt(n) and n % i == 0)
{
c += 1;
s += i;
}
}
cout << c << " " << s;
}
Помогите пожалуйста. Сайт пишет что программа выдаёт неверный ответ
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question