As something new, I am trying to complete the Project Euler 5 task with a script package ( https://projecteuler.net/problem=5 ). But; I ran into a few problems. If anyone could skip my code, that would be great.
@ECHO off SET init=1 SET iter=1 SET /a func=%init% %% %iter% cls :Num IF func==0 ( IF iter==20 ( ECHO Val = %init% pause exit ) ELSE ( SET /a iter+=1 GOTO Num ) ) ELSE ( SET iter=1 SET /a init+=1 GOTO Num )
What you need to do is check if the init mod iter returns 0, and if so, add 1 to the iter until it reaches 21. However; if it is not 0, the iteration counter will be set to 0 and will begin to be calculated again.
An example of what will happen MEANT:
1 mod 1 = 0, Therefor add 1 to iter 1 mod 2 != 0, Therefor init is set to 0 and 1 is added to init 2 mod 1 = 0, Therefor add 1 to iter 2 mod 2 = 0, Therefor add 1 to iter 2 mod 3 != 0, Therefor init is set to 0 and 1 is added to init
And so on and so forth.
An example of what is happening:
1 mod 1 != 0, Therefor add 1 to init 2 mod 1 != 0, Therefor add 1 to init 3 mod 1 != 0, Therefor add 1 to init
And so on and so forth.
Any help is appreciated, thanks.
source share