title: Prime Number Theorem Python
body: <p>I am attempting to support the prime number theorem by using the attached code. I would like to somehow show that the average gap between prime numbers less than n is log(n). The code that I have right now can determine whether a certain number is prime, and then the second part calculates the prime gap for each consecutive prime in my range. Any ideas for how to proceed in python using the following code?</p>
  
  <pre><code>from pylab import *
  
  def Is_Prime (n):
      if n==1:
          return False
      if n == 2 or n == 3:
          return True
      if n == 4:
          return False
      if n%2 == 0 or n%3 == 0:
          return False
  
      for i in range(5,int(n**0.5)+1,6):
          if n%i == 0 or n%(i+2) == 0:
              return False
  
      return True
  
  k = 0
  for i in range (1,100):
      if Is_Prime(i) == True:
          print(i)
          k+=1
  print "Total number of prime numbers in [1,100] is", k
  
  
  previous = 2
  n = 0
  for i in range(3,100000):
      if Is_Prime(i):
          n = n+1
          current  = i
          gn = current - previous
              print gn
          plot(n,gn,'rs')
          xlabel('n')
          ylabel('g(n)')
          previous = i
          if n == 100:
              break
  
  show()
  </code></pre>