Write a function of totalDivisors(int), which takes the number as parameter and the function will display all of the divisors till that number from 1. Calculate and return the total number of the divisors from the function in c++?
Answers
Answer:
Sign InHomeCoursesAlgorithmsData StructuresLanguagesInterview CornerGATECS SubjectsStudentJobsGBlogPuzzlesWhat's New ?
Related Articles
▲
Related Articles
Find all divisors of a natural number | Set 2Find all divisors of a natural number | Set 1Count Divisors of n in O(n^1/3)Total number of divisors for a given numberWrite an iterative O(Log y) function for pow(x, y)Write a program to calculate pow(x,n)Modular Exponentiation (Power in Modular Arithmetic)Modular exponentiation (Recursive)Modular multiplicative inverseEuclidean algorithms (Basic and Extended)Program to find GCD or HCF of two numbersProgram to find LCM of two numbersLCM of given array elementsFinding LCM of more than two (or array) numbers without using GCDGCD of more than two (or array) numbersSieve of EratosthenesSieve of Eratosthenes in 0(n) time complexityHow is the time complexity of Sieve of Eratosthenes is n*log(log(n))?Segmented SieveSegmented Sieve (Print Primes in a Range)Prime Factorization using Sieve O(log n) for multiple queriesEfficient program to print all prime factors of a given numberPrime FactorPollard’s Rho Algorithm for Prime FactorizationProgram for Fibonacci numbersWrite a program to print all permutations of a given stringCoin Change | DP-7Set in C++ Standard Template Library (STL)C++ Data Types
Find all divisors of a natural number | Set 1
Difficulty Level : EasyLast Updated : 12 Oct, 2020
Given a natural number n, print all distinct divisors of it.
Examples:
Input : n = 10 Output: 1 2 5 10 Input: n = 100 Output: 1 2 4 5 10 20 25 50 100 Input: n = 125 Output: 1 5 25 125