windows - Batch Program - Prime Number Checker -
i'm programming in batch using fact forall n
between 1 , 100, (2^n-2) mod n
0 if n
prime, , not 0 if otherwise. when run program, "missing operator" error. flaw in code?
@echo off color f0 title prime number checker echo -------------------------------------------------------- echo prime number checker v1.0 echo -------------------------------------------------------- echo. set /p n=enter number between 1 , 100: set result=1 set i=1 :multiply set /a result=result*2 set /a i=i+1 if %i% lss %n% goto multiply set /a result = result - 2 set /a result = result % n if %result% == 0 echo number prime. if %result% neq 0 echo number not prime. pause <nul
Comments
Post a Comment