1.

Solve : Random number less than x?

Answer»

i am making this batch file and basically i need to generate a random number LESS than or equal to 25.

i know about the command %random% but everything i have TRIED doesn't work

thank youCode: [SELECT]@echo off
:loop
set /a "num=%random% %% 26"
if %num% EQU 0 goto :loop
echo %num%
goto :loop
Works for me.
What did you expect it to do?

You can do it in ONE line

set /a num=%random% %%25 +1
Good thinking BatmanThe number 0 is the smallest non-negative integer. He didn't actually say that zero is excluded, did he? Speaking mathematically, 0 may or may not be considered a natural number, but it is a whole number and hence a rational number and a real number (as WELL as an algebraic number and a complex number).




Discussion

No Comment Found