ArjanCodes / 2023-decorator

MIT License
39 stars 6 forks source link

Bug in decorator_func.py / is_prime, line 32 #2

Open SoundDesignerToBe opened 1 year ago

SoundDesignerToBe commented 1 year ago
count_prime_numbers(20)
Traceback (most recent call last):
  File "C:\Users\...\IPython\core\interactiveshell.py", line 3548, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-16-2ef7e3e47e26>", line 1, in <module>
    count_prime_numbers(20)
  File "<ipython-input-15-68e32e7a376c>", line 10, in wrapper
    value = func(*args, **kwargs)
  File "<ipython-input-15-68e32e7a376c>", line 20, in wrapper
    value = func(*args, **kwargs)
  File "<ipython-input-15-68e32e7a376c>", line 43, in count_prime_numbers
    if is_prime(number):
  File "<ipython-input-15-68e32e7a376c>", line 32, in is_prime
    for element in range(2, sqrt(number) + 1):
TypeError: 'float' object cannot be interpreted as an integer

(Python 3.10.0)

SoundDesignerToBe commented 1 year ago

fix suggestions: for element in range(2, int(sqrt(number) + 1)):