Algorithm


A. Numbers
time limit per test
1 second
memory limit per test
64 megabytes
input
standard input
output
standard output

Little Petya likes numbers a lot. He found that number 123 in base 16 consists of two digits: the first is 7 and the second is 11. So the sum of digits of 123 in base 16 is equal to 18.

Now he wonders what is an average value of sum of digits of the number A written in all bases from 2 to A - 1.

Note that all computations should be done in base 10. You should find the result as an irreducible fraction, written in base 10.

Input

Input contains one integer number A (3 ≤ A ≤ 1000).

Output

Output should contain required average value in format «X/Y», where X is the numerator and Y is the denominator.

Examples
input
Copy
5
output
Copy
7/3
input
Copy
3
output
Copy
2/1
Note

In the first sample number 5 written in all bases from 2 to 4 looks so: 101, 12, 11. Sums of digits are 2, 3 and 2, respectively.



 

Code Examples

#1 Code Example with C++ Programming

Code - C++ Programming

#include <cstdio>

long gcd (long a, long b){return (b == 0) ? a : gcd (b, a%b);}

long findDigitSum(long number, long base){
    long total(0);
    while(number > 0){total += number % base; number /= base;}
    return total;
}

int main(){
    long A(0); scanf("%ld", &A);
    long totalSum(0); for(long k = 2; k < A; k++){totalSum += findDigitSum(A, k);}
    long currentGcd = gcd(totalSum, A - 2);
    printf("%ld/%ld\n", totalSum/currentGcd, (A - 2)/currentGcd);
    return 0;
}
Copy The Code & Try With Live Editor

Input

x
+
cmd
5

Output

x
+
cmd
7/3
Advertisements

Demonstration


Codeforces Solution-A. Numbers-Solution in C, C++, Java, Python

Previous
Codeforces solution 1080-B-B. Margarite and the best present codeforces solution
Next
CodeChef solution DETSCORE - Determine the Score CodeChef solution C,C+