title: Concatenation of Consecutive Binary Numbers, Modulo Operation discussion behavior
body: <p>Here I am contributing the Java Solution for the problem.
  Concatenation of Consecutive Binary Numbers:
  Given an integer n, return the decimal value of the binary string formed by concatenating the binary representations of 1 to n in order, modulo 10^9 + 7.</p>
  <pre><code>class Solution {
      public int concatenatedBinary(int n) {
          long sum = 0;
      
          for(int i = 1; i &lt;= n; i++){
              sum = ((sum &lt;&lt; Integer.toBinaryString(i).length()) + i) % 1000000007;
          }
      
          return (int) sum;
      }
  }
  </code></pre>
  <p>Now I have a doubt that is when we are modulating at each step within for loop. It will not impact the result till 1000000007 but after that, it will change the sum variable, and this cycle will repeat. Now, why doesn't this modulo impacting the overall result? Thanks in advance.</p>