python - Random Odd Numbers -


my professor gave our first assignment (cs315), involves dealing huge (odd) integers , determining if prime. started in c++ until realized long long ints not hold numbers needed, left choices of making class of vectors in c++, or learning python in few days. simple piece of python code supposed spit out odd 256 bit random number. spits out random numbers, both , odd, , don't know why, guess is simple syntactical error not seeing.

import random x = random.getrandbits(256) if x % 2 == 0:     x +  1 print x 

you need assign x + 1 x. can either this: x = x+1 or this: x += 1


Comments

Popular posts from this blog

angular - Is it possible to get native element for formControl? -

unity3d - Rotate an object to face an opposite direction -

javascript - Why jQuery Select box change event is now working? -