SoFunction
Updated on 2025-04-13

Code to solve mathematical problems with batch processing page 4/4


【10】by [youxi01]
========================================================================================

@echo off
echo is detecting data......
setlocal enabledelayedexpansion
set /a flag=0
for /l %%i in (10000,1,99999) do (
set num=%%i
The rem is added 1 in front of it to prevent special situations similar to 30820.
set /a num=1!num:3=!
if !num! lss 2000 if !num! gtr 200 set /a flag+=1)
echo %flag%
echo The test is completed!
pause>nul

========================================================================================
【11】by [youxi01]
========================================================================================
:: Question 11 is a little harder. Using high school mathematical knowledge, it can be proved that any number greater than or equal to 4 can have two such numbers.
The sum of :: is equal to the number, and the product must be greater than or equal to the number. Based on this inference, all numbers will eventually be broken into this form:
::A*A*A*A...A is 2 or 3 (because there are only 2 and 3 that cannot be disassembled, and the rest must be only 2 and 3). So we can get the following
::'s code: (The answer is 486, I don't know if it's right ^-^)

@echo off
setlocal enabledelayedexpansion
set num=17
set /a Cnum=%num%/3
set /a Rnum=%num%%%2
set /a Tnum=0
for /l %%i in (%Rnum% 2 %Cnum%) do (
set num_=1
set /a num_tem=%num%/2-%%i*3/2
for /l %%a in (1 1 %%i) do (
set /a num_*=3)
for /l %%b in (1 1 !num_tem!) do (
set /a num_*=2)
if !num_! gtr !Tnum! set /a Tnum=!num_!
)
echo !Tnum!
pause>nul

========================================================================================
【12】by [youxi01]
========================================================================================

@echo off
echo is detecting data......
setlocal enabledelayedexpansion
set /a num=1
set /a flag=0
for /l %%i in (2 1 10000) do (
call :test %%i
echo %%i !flag!)

:exit
The smallest natural number of echo is:!num!
echo.
echo The test is completed!
pause>nul

:test
set /a num=!num!*%1
for /l %%i in (1 1 5) do (
if !num:~-1! EQU 0 (set /a flag+=1 & set /a num=!num:~0,-1!) else (
set /a num=!num:~-1! & goto :eof))

========================================================================================
【13】by [youxi01]
========================================================================================

@echo off
echo is detecting data......
setlocal enabledelayedexpansion

for /l %%a in (90 1 180) do (
for /l %%b in (1 1 %%a) do (
set /a num=%%a %% %%b
if !num! EQU 0 (
set /a num=%%a/%%b
set /a num_=!num!+%%a+%%b
If !num_! EQU 181 echo There are numbers like this, divisor: %%a Divisor: %%b Quotation: !num!
)
)
)
echo.
echo The test is completed!
pause>nul
Previous page1234Read the full text