#P17347. [ECNA 2025] Fractional Sequence

[ECNA 2025] Fractional Sequence

Problem Description

Consider the following increasing sequence, SS, of rational numbers:

$$1,\; 2,\; 2\frac{1}{2},\; 3,\; 3\frac{1}{3},\; 3\frac{2}{3} ,\; 4,\; 4\frac{1}{4},\; 4\frac{1}{2},\; 4\frac{3}{4},\; 5,\; 5\frac{1}{5},\; 5\frac{2}{5},\; 5\frac{3}{5},\; 5\frac{4}{5},\; 6,\; \ldots .$$

SS is composed of an infinite set of blocks, N1,N2,N3,N_1, N_2, N_3, \ldots, where block NiN_i is $$i,;; i+1/i,;; i+2/i,;; \ldots, ;; i+(i-1)/i .$$ So S(1)=1,S(2)=2,S(3)=212S(1) = 1, S(2) = 2, S(3) = 2\frac{1}{2}, etc. Write a program which takes as input an integer nn and outputs S(n)S(n).

Input Format

Input is a single line containing an integer, nn (1n41091 \leq n \leq 4\cdot 10^9).

Output Format

Output S(n)S(n) as a single integer if the answer is a whole number. Otherwise, output the integer part, a single space and a proper fraction a/ba/b in lowest terms (i.e. 0<a<b0 < a < b and GCD(a,b)=1GCD(a,b) = 1). See the sample outputs.

326
26
448
30 2/5
4000000000
89443 19596/89443