# Do golfing languages support rational number arithmetic?

I proposed this code golf on sandbox:

# Integer Logarithm

Take $$\a \in ℤ_{>1}\$$ and $$\b \in ℤ_+\$$ as inputs. Write a function $$\f\$$ that:

$$f(a,b) = \left\{ \begin{array}{ll} \text{Just} \space \log_ab & \quad \text{if} \space \log_ab \in ℚ \\ \text{Nothing} & \quad \text{otherwise} \end{array} \right.$$

## Rules

• Types and formats of the inputs doesn't matter, but they must be able to represent at least 2 bits. For example, in C++, int, unsigned, std::vector<bool>, or even std::string containing ASCII digits are acceptable.

• Type and format of the output doesn't matter either, but the fraction must be irreducible. In C++, std::optional<std::pair<int,unsigned>> is an example.

• You must not use floating-point numbers because of their errors.

• if $$\a\$$ and $$\b\$$ aren't in the sets as specified above, the challenge falls in don't care situation.

• $$\f\$$ may be curried or uncurried.

• As this is a code-golf, the shortest code in bytes wins.

But to think about it, I doubt that golfing languages natively support rational number arithmetic. Unlike this challenge, it actively requires arithmetics on rational numbers, in sake of, for example, Newton's method.

Do major golfing languages such as 05AB1E, Jelly, APL, and Charcoal natively support rational number arithmetic?

• Can't this be done using just integer types? – xnor Feb 13 at 6:24
• @xnor Do you mean you want $\log_a{b} \in \mathbb{Z}$? – Dannyu NDos Feb 13 at 6:25
• No, I mean the solver can work with just integers by finding p,q so that a^q = b^p, and outputting p/q. Actually, even the ratio of their respective counts of prime factors in their factorizations should suffice. – xnor Feb 13 at 6:26
• @xnor Aha! So it is possible with just integer types. Thanks. I will post it in few hours if there is no objections. – Dannyu NDos Feb 13 at 6:29