Menu
Coddy logo textTech

Greatest Divisors

Lesson 17 of 25 in Coddy's Coding Problems: Volume 2 course.

You will be given a number N and your task is to find the number with the largest sum of its divisors that is smaller than N. A divisor is a number that divides another without a remainder

challenge icon

Challenge

Medium

Write a program that from standard input reads a natural number N and finds the number smaller than N that has the largest sum of divisors

Input
10

Output
8

Explanation
The sum of divisors of 8 is 1+2+4 = 7, the largest sum of divisors of any number smaller than 10

Try it yourself

#include <stdio.h>

int main() {
    // Write code here
    return 0;
}

All lessons in Coding Problems: Volume 2