Untitled

mail@pastecode.io avatar
unknown
plain_text
7 months ago
820 B
4
Indexable
Never
#include <stdio.h>

int main() {
    int maxNum = 0;
    int maxSum = 0;

    

    for (int num = 180; num <= 210; num++) {
        int divisors_sum = 0;
        printf("%d\t", num);
        int divisorCount = 0; 

        for (int i = 2; i <= num / 2; i++) {
            if (num % i == 0) {
                divisors_sum += i;
                printf("%d, ", i);
                divisorCount++;

                
                if (divisorCount == 4) {
                    printf("\n\t");
                    divisorCount = 0; 
                }
            }
        }

        if (divisors_sum > maxSum) {
            maxSum = divisors_sum;
            maxNum = num;
        }

        printf("\t%d\n", divisors_sum);
    }

    printf("\n%d\n", maxSum, maxNum);

    return 0;
}