Search
 
SCRIPT & CODE EXAMPLE
 

CPP

divisor summation

#include<iostream>
using namespace std;

int main() {

		int t;
    cin >> t;
    while (t--) {
        int n;
        cin >> n;


        int sum = 0;
        for (int i = 1; i * i <= n; i++) {
            if (n%i == 0) {
                sum += i;
                if (i != n/i) {
                    sum += n / i;
                }
            }
        }

        cout << sum - n << endl;
    }

		return 0;

}
Comment

PREVIOUS NEXT
Code Example
Cpp :: kadane algo 
Cpp :: c++ camera capture 
Cpp :: copy file to vector c++ 
Cpp :: stricmp CPP 
Cpp :: The Rating Dilemma codechef solution in c++ 
Cpp :: nand in cpp 
Cpp :: c++ bind port 
Cpp :: how to signify esc key in cpp 
Cpp :: . Shell sort in c++ 
Cpp :: opengl draw cresent moon c++ 
Cpp :: c++ program for inflation rate of two numbers 
Cpp :: reverse a stack in c++ using another stack 
Cpp :: big o notation practice c++ 
Cpp :: c++ require keyword 
Cpp :: c++ to c code converter 
Cpp :: find node from pos linkedlist c++ 
Cpp :: estimateaffine3d example c++ 
Cpp :: cpprestsdk header 
Cpp :: convert java to c++ 
Cpp :: play roblox vr on quest 2 
Cpp :: initialize object as null in c++ 
Cpp :: pop back innstring 
Cpp :: C++ check if thread is joinable 
Cpp :: check if number is positive or negative in cpp 
Cpp :: sort array using stl 
Cpp :: glm multiply vector by scalar 
Cpp :: c++ loop through an array 
Cpp :: determining whether a array is a subsequence of another array 
Cpp :: sort in descending order c++ 
Cpp :: hwo to send token on redirection in passport 
ADD CONTENT
Topic
Content
Source link
Name
4+2 =