2 ms·
I still find that the sortest one is this: take the prime factors of n, the primes with even power go to the numerator with halved powers, the primes with odd
by szemet 8y ago
I still find that the sortest one is this:
take the prime factors of n, the primes with even power go to the numerator with halved powers, the primes with odd powers go to the denominator also with halved powers but rounded up. This is bijective, due to the uniqueness of prime factorization, and of course the numerator and denominator greatest divisor is also guaranteed to be 1, as they not share prime factors at all. So e.g.
45 = 3²5¹-> 3/5
60 = 2²3¹*5¹ -> 2/15
2 -> 1/2, 3 -> 1/3, 4 -> 2/1, 5 -> 1/5, 6 -> 1/6, 7 -> 1/7, 8 -> 1/4, 9 -> 3/1, ...