批处理程序 - 素数检查器

时间:2016-01-27 19:27:33

标签: windows batch-file cmd

我正在批量编程,使用forall n介于1和100之间,(2^n-2) mod n如果n为素数则为0,否则为0。当我运行程序时,出现“缺少运算符”错误。我的代码中有什么缺陷?

@echo off
color F0
title Prime Number Checker
echo --------------------------------------------------------
echo  Prime Number Checker v1.0
echo --------------------------------------------------------
echo.
set /p n=Enter a number between 1 and 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 The number is prime.
if %result% NEQ 0 echo The number is not prime.
pause <nul

0 个答案:

没有答案