using
System;
using
System.Collections.Generic;
class
GFG
{
static
readonly
int
MAX = 100001;
class
pair
{
public
int
F, S;
public
pair(
int
f,
int
s)
{
F = f;
S = s;
}
}
static
List<pair> []factors =
new
List<pair>[MAX];
static
void
sieveOfEratothenese()
{
bool
[]isPrime =
new
bool
[MAX];
for
(
int
i = 0; i < MAX; i++)
isPrime[i] =
true
;
isPrime[0] = isPrime[1] =
false
;
for
(
int
i = 2; i < MAX; i++)
{
if
(isPrime[i])
{
for
(
int
j = i; j < MAX; j += i)
{
int
k, l;
isPrime[j] =
false
;
for
(k = j, l = 0; k % i == 0; l++, k /= i)
;
factors[j].Add(
new
pair(i, l));
}
}
}
}
static
int
sumOfProperDivisors(
int
num)
{
int
mul = 1;
for
(
int
i = 0; i < factors[num].Count; i++)
mul *= (
int
)((Math.Pow(factors[num][i].F,
factors[num][i].S + 1) - 1) /
(factors[num][i].F - 1));
return
mul - num;
}
public
static
void
Main(String[] args)
{
for
(
int
i = 0; i < MAX; i++)
factors[i] =
new
List<pair>();
sieveOfEratothenese();
int
[]arr = { 8, 13, 24, 36, 59, 75, 91 };
for
(
int
i = 0; i < arr.Length; i++)
Console.Write(sumOfProperDivisors(arr[i])+
" "
);
Console.WriteLine();
}
}