#!/bin/python3

from random import randint
from math   import log
from math   import sqrt
import time
import timeit
import matplotlib.pyplot as plt
import argument as arg

def weight( n ) :
    r  = 0
    while  n > 0 :
        r = r + 1
        n = n & ( n-1)
    return r


print( 'r=', arg.repetition, 'i=',arg.iteration )
x = []
y = []
z = []
s = 0
w = 0
for n in  range(0 , arg.iteration  ) :
    x.append( n )
    y.append( s )
    z.append( w*32 )
    w = weight( n) 
    s = s+w 

plt.title("somme des poids")
plt.xlabel('n')
plt.plot(x, y, label="s")
plt.plot(x, z, label="w")
plt.legend()
plt.grid(True)

plt.show()
plt.close()


