title: Performing Modulus Arithmetic Within a Batch Script
body: <p>As something new, I'm trying to complete Project Euler Problem 5, with a batch script (<a href="https://projecteuler.net/problem=5" rel="noreferrer">https://projecteuler.net/problem=5</a>). However; I've run into a few problems. If anyone could go over my code, that'd be great.</p>
  
  <pre><code>@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
  )
  </code></pre>
  
  <p>What it's meant to do is check whether the <code>init mod iter</code> returns a 0, and if it does, add 1 to the <code>iter</code> value, until it reaches 21.  However; if it does not equal 0, the iteration count will be set back to 0 and will start calculating again.
  <hr>
  An example of what's MEANT to happen:</p>
  
  <pre><code>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
  </code></pre>
  
  <p>And so on and so forth.
  <hr>
  An example of what DOES happen:</p>
  
  <pre><code>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
  </code></pre>
  
  <p>And so on and so forth.
  <hr>
  <br>
  Any help is appreciated, thanks.</p>