title: Why is the time function working differently in both these cases?
body: <p>I am solving Problem 14 of Project Euler and I wrote 2 programs, one which is optimised and the other which is not. I've even imported the time module to calculate the time taken, but it's not working properly. it works fine in the unoptimised code:</p>
  <pre><code>import time
  start = time.time()
  def collatz(n):
      chain=1
      while(n&gt;1):
          chain+=1
          if(n%2==0):
              n/=2
          else:
              n = 3*n+1
      return chain
  
  maxChain = 0
  num=0
  counter = 10**6
  
  while(counter&gt;13):
      coll = collatz(counter)
      if(coll &gt; maxChain):
          maxChain = coll
          num = counter
      counter-=1
  end = time.time()
  print(&quot;Time taken:&quot;,end-start)
  print(start+', '+ end)
  </code></pre>
  <p>the output is:</p>
  <pre><code>Time taken: 47.83728861808777
  1591290440.8452923, 1591290488.682581
  </code></pre>
  <p>But in my other code:</p>
  <pre><code>import time
  start = time.time()
  
  dict = {n:0 for n in range(1,10**6)}
  dict[1], dict[2] = 1,2
  
  for i in range(3,10**6):
      counter = 0
      start = i
  
      while(i &gt; 1):
          #Have we already encountered this sequence?
          if(i &lt; start):
              dict[start] = counter + dict[i]
              break
          
          if(i%2==0):
              i/=2
          else:
              i = 3*i+1
          counter += 1
  
  
  end = time.time()
  print('Time taken:',end-start)
  print(start+', '+end)
  </code></pre>
  <p>the output is:</p>
  <pre><code>Time taken: 1590290651.4527032
  999999, 1591290650.4527032
  </code></pre>
  <p>The start time in the second program is 999999 while the end time is fine. this problem doesn't occur in the first program, I don't know why this is happening?</p>