-
MathType
-
Wiris Quizzes
-
Learning Lemur
-
CalcMe
-
MathPlayer
-
Store FAQ
-
VPAT for the electronic documentation
-
MathFlow
-
BF FAQ
Examples
Reading time: 2minSum of two random irreducible fractions
Consider creating an exercise where students must calculate the sum of two randomly generated irreducible fractions.
# Generate the first fraction
# Choose a random numerator "a" from 1 to 9
a = random(1,9)
# Define set "B" of denominators that are coprime with "a"
B = { b with b in 2..9 where gcd(a,b)=1 }
# Choose random denominator "b" from set B
b = random(B)
# Generate the second fraction
# Choose another random numerator "c" from 1 to 9
c = random(1,9)
# Define set "D" of denominators coprime with "c", different from "b"
D = { d with d in 2..9 where gcd(c,d)=1 && d!=b }
# Choose random denominator "d" from set "D"
d = random(D)
# Calculate the sum of the two irreducible fractions
# The solution the students will calculate
sol = a/b + c/d

Solving linear equations with integer solutions
Consider creating a linear equation with random coefficients, ensuring that the solution is an integer.
# Generate a quadratic equation ax^2 + bx + c = 0
with integer/rational solutions by ensuring discriminant is a perfect square.
# Generate random values for the coefficients
a = random([-10..10]/[0])
b = random([-10..10]/[0])
c = random([-10..10]/[0])
# Ensure the discriminant=b^2-4*a*c is a perfect square. If not, regenerate value "c".
while square?(b^2-4*a*c) == false
do c = random([-10..10]/[0])
# At this point, we have a valid quadratic equation with rational solutions
solution1 = (-b + sqrt(discriminant)) / (2*a)
solution2 = (-b - sqrt(discriminant)) / (2*a)
Tip: When you're using the same logic multiple times—like generating random numbers with the same rules—you can define a function to avoid repeating yourself. This makes your code easier to read and maintain.
r():= random([-10..10]/[0])
a=r()
b=r()
c=r()
Greatest common divisor of two random integers
Consider creating an exercise where students must calculate the GCD of two random integers.
# Randomly select target GCD between 2 and 10
target_gcd = random(2,10)
# Select two random integers that are coprime (so gcd=1)
repeat
m = random(2,10)
n = random([2,10]/[m])
until gcd(m, n) == 1
# Generate integers ensuring exact GCD is target_gcd
x = m * target_gcd
y = n * target_gcd
# Students should find the gcd of "x" and "y"
solution = target_gcd
Division with no remainder (exact division)
Consider creating an exercise where students divide two integers, ensuring that the result is an exact integer without remainder
# Select a random divisor from 2 to 12
divisor = random(2,12)
# Choose a random integer quotient between 2 and 10
quotient = random(2,10)
# Compute dividend ensuring exact division
dividend = divisor * quotient
# Students perform the division: dividend ÷ divisor
solution = quotient