Here is the challenge as proposed by @trichoplax thanks to him for consolidating my post and standarizing it to PPCG common-rules.
- A galaxy is a group of numbers where each one is mapped to another via a precise function f either a symbolic one or mathematical, a structure of numbers sharing some common points with this challenge i got inspired from with an exception that a galaxy sequence is not cyclic, but holds in a black hole, where more than one number can be mapped to it.
- A black hole is a specific unique number from a galaxy where all numbers (not individually) are mapped transitively to it, by repeating a function f infinitely over an infinite far number in a same galaxy, or just once if a number is the closest in the same galaxy, for example if the function is the ceiling of the square root then a black hole for the biggest galaxy so far excluding only the number 1 is
2
, because mapping the closest number3
or the infinite repetitively leads to the same number.
Task
Conceive a universe of an infinite number of distinct galaxies where all galaxies encompass an infinite number of integers.
Note that the example of ceiling of square root is banned for two reasons:
- The galaxy {1} is finite.
- There is a finite number of galaxies.
A valid example, is dividing by the smallest prime factor. This gives an infinite number of infinite galaxies.
2*2*3*5*5*7, 2*3*5*5*7, 3*5*5*7, 5*5*7, 5*7, 7, 7*5*5*5, 7*5*5*5....
5*5*7*11, 5*7*11, 11*7*7*7... , ....
...
Or one galaxy as a tree:
2*2*5 - 2*5 \
\
2*3*5 - 3*5 - 5
3*3*5 / |
/
2*5*5 - 5*5 /
3*5*5 /
Each galaxy consists of all numbers that share the same largest prime factor, and the function takes them all step by step towards the black hole which is that prime factor.
Note also, you may choose any domain of integers as long as the range is infinite, i mean you can exclude a range of numbers that makes the rest still boundless like {1,0} from last example.
Your program takes any integer input via a function's dimension , STDIN, and outputs an integer as the image mapped from this preimage, otherwise prints "error" or any string prespecified for an outputless range of enteries.
For the same example:
(IN/OUTPUT)
20
10
15
5
77
11
0
'undefined'
1
'undefined'
This is code-golf so shortest program in bytes wins.
I would have really liked to add a bonus-score for anyone who succeeds to find a function generating a universe without trees, alas, bonuses for code-golf are excluded.