I want to generate (multiple) random numbers from a given number class with extra conditions. (for automatic generation of exercises)


  • generate "a" out of natural Numbers which are dividible by three
  • generate "b" which is a rational number but not natural number
  • generate "c" and "d" which are both prime numbers and "d" is at least twice as big as "c"

ideally also:

  • generate "f" as a polynomyal function of grade 2

My plan is to write a little script that will be then run multiple times from maxima and maxima outputs new tasks (with their solutions) every time.

my idea (pseudocode)

a := random(natural_numbers) | rest(a / 3) = 0
solution := 1/3 + 2/a

and this would output an "a" that I can use to build the exercise as well as a "solution" that i can check against.

  • $\begingroup$ you cant generate random natural uniformly distributed or unbounded because there is computational limitation in the number of ciphers a number can achieve. The best you can do is use a random number generator in a bounded set of naturals, by example choosing naturals from 1 to 100. Anyway this doen't seems the best stackexchange forum for this question $\endgroup$ – Masacroso Nov 18 '18 at 0:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.