Math Division Problem

I’m creating a math equation generator which involves divisions. My problem is, how do I check if the divisions’ answers aren’t repeating/infinite?

Can you please elaborate on what you mean, possibly including examples?

Here are some examples of divisions with repeating decimals:
1/3 = 0.33333…
1/7 = 0.142857142857…
1/11 = 0.09090909…
Without repeating decimals:
1/2 = 0.5
1/4 = 0.25
1/5 = 0.2
1/8 = 0.125
1/10 = 0.1

What I want is to filter out those with repeating decimals

1/7 isn’t repeating. do you just mean non-terminating decimals?

To be honest, the computer won’t perceive any number as irrational, as it would just cut off after a time period. The best way that I can think of is just to manually make a list of all non-terminating number denominators (for 1/X) and check if thats what the calculation will carry out.

Someone else may have a better idea of how to do it though?

I was hoping for an algorithm but this may work.

You can probs look for string.match() whenever you want to check if the answer is correct or not and string.sub() when ever you want to show the answer

You can just use math.round to round the number however many decimal places you want.
example:
variableName = math.round(variableName * 1000) / 1000
rounds varialbleName to 4 decimal places
1.333… would become 1.333 using the following steps:
multiply 1.333… by 1000 to get 1333.333…
then round it to get 1333
then divide by 1000 to get 1.333