The following example either finds a factor of the number $n$ or returns a message saying that the number in question is prime (I specifially wrote this to demonstrate my question below).
n = 125; For[i = 2, i <= Sqrt[n], i++, If[Mod[n, i] == 0, Print["Factor found: ", i]; Break;] ] If[i <= Sqrt[n], Exit;] Print[n, " is prime."] ...
I know I could simply include the last Print statement in the if-condition, but I am specifically looking for a command that makes Mathematica skip the last Print statement (and all other statements that might come thereafter...). I tried Break, Abort and Interrupt, but none have the desired effect.
Now the commands Exit and Quit work, but they terminate the entire Mathematica kernel, which is a bit of an overkill. How could I bypass this issue? I need something like SkipRemainingCommands.