##QBIC, 35 32 bytes
QBIC, 35 32 bytes
This brought me here.
:{p=0[a|~q%b|p=1]]~p=0|_Xq\q=q+1
Explanation:
: Get cmd line param as number 'a'
{ Start an infinite DO loop
p=0 Sets a flag that shows if divisions failed
[a| FOR (b=1; b<=a; b++)
~q%b IF 'q' (which starts at 1 in QBIC) is not cleanly divisible by 'b'
|p=1 THEN Set the flag
]] Close the FOR loop and the IF, leave the DO open
~p=0 IF 'q' didn't get flagged
|_Xq THEN quit, printing 'q'
\q=q+1 ELSE raise 'q', redo
[DO Loop implicitly closed by QBIC]
Here's a version that stops testing q
when b
doesn't cleanly divide it. Also, the order of testing b
's against q
is reversed in the assumption that higher b
's will be harder to divide by (take 2
, 3
, 4
for instance: if %2=0
, %4
could be !0
. Vice versa not so much...).
:{p=0[a,2,-1|~q%b|p=1┘b=2]]~p=0|_Xq\q=q+1