我决定我想自动解决一个数学谜题,但是,它在 python 中不起作用,虽然我已经成功地批量完成了它:
@echo off
set people=1
set handshakes=0
set cnt=0
:LOOP
set /A people+=1
set /A cnt+=1
set /A handshakes+=%cnt%
echo.handshakes:%handshakes%,people=%people%
if "%handshakes%" NEQ "66" Goto :LOOP
echo.---------Final Result------------
echo.Handshakes:%handshakes%
echo.People:%people%
pause > nul
exit /b
但是出于一个非常奇怪的原因,以下 python 代码不起作用:
people = 1
handshakes = 0
cnt = 0
while a < 66:
people+=1
cnt+=1
handshakes+=cnt
print (handshakes)
print (people)
raw_input()
谜语:在聚会上,每个人都与其他人握手。有66次握手。聚会有多少人?