Tcl, 78 7575 74 bytes
Thanks to sergiol
if $argv<2 {exit 1} incr d while {[incr d]<$argv} {if $argv%$d==0$argv%$d<1 {exit 1}} Original version
if {$argv<2} {exit 1} incr d while {[incr d]<$argv} {if {$argv%$d==0} {exit 1}} Works for all integer values (both negative and arbitrarily large). However, as this aims to be short and not efficient, it is written with a simple divisor={2,3,4,...} loop, so you'll begin getting noticeable lag around eight digit numbers (n ≥ 108).
The input is taken on the command-line; the output is an exit code: 0 for prime and 1 for not prime.
On Windows you can use the following batch file to test it:
@echo off tclsh a.tcl %1 if ERRORLEVEL 1 ( echo not prime ) else ( echo prime ) Use it as:
C:\foo> run.bat 2017 prime *On nixen you can use the following bash script to test it:
#! /bin/sh tclsh a.tcl $1 if [ $? -eq 0 ] then echo prime else echo not prime fi Use it as:
% ./run.sh 2017 prime Enjoy!