NG0FRCTN - Fractions on Tree


A fraction tree is an infinite binary tree defined as follows:

  1. Every node of tree contains a fraction.
  2. Root of tree contains the fraction 1/1.
  3. Any node with fraction i/j has two children : left child with fraction i/(i+j) and right child with fraction (i+j)/j.

For example, fraction tree up to 3 levels is as shown:

Fraction tree up to 3 levels

We number the nodes according to increasing levels (root is at level 1) and at any same level, nodes are numbered from left to right. So first node holds the fraction 1/1, second one holds 1/2, third one holds 2/1 fourth one holds 1/3 and so on.

Your task is simple. Given a number n, you are to find the fraction at the nth node.

Input

Every line of the input contains a single number n. You are to find the fraction at nth node of fraction tree. Input file terminates with a 0 which is not to be processed.

Output

For each input, print numerator and denominator of the lowest form of the fraction separated by a /. Output of each case to be done in separate lines.

Example

Input:
1
2
3
7
0

Output:
1/1
1/2
2/1
3/1

Constraints

1 <= number of test cases <= 30000, 1 <= N <= 10^10


hide comments
[Retired] Fendy Kosnatha: 2011-03-29 02:41:53

image is visible, please updated...

Nikhil Garg: 2010-11-22 13:28:23

Problem Statement updated. Thanks :)

Seshadri R: 2010-05-17 14:38:21

Constraints : 1<=T <=30000 1<=N<=10^10. Does T correspond to the number of test cases? It has not come out clearly in the problem statement

Last edit: 2010-05-17 14:39:24

Added by:Nikhil Garg
Date:2009-12-19
Time limit:1.440s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: NODEJS OBJC PERL6 SQLITE VB.NET
Resource:own