Python Tutorial: How to find all Prime Numbers in a given range [ Prime Numbers in Python]

Поделиться
HTML-код
  • Опубликовано: 24 апр 2021
  • In this video you will learn how to create a simple python program to find all prime numbers between two other number. You can also use the program to determinate if a number is prime number.
    Please LIKE and SUBSCRIBE for more content and supporting!
    #python #primenumber
    Tags:
    python prime numbers
    Python find all Prime Numbers in a given range
    Python how to find prime numbers in a range
    Finding prime numbers in python

Комментарии • 3

  • @memy4460
    @memy4460 Год назад +3

    It is a good video, but I don't understand why the math.sqrt is needed. We did it this way:
    number = int(input('Type in the number you want ot check: '))
    isPrime = True
    for i in range(2, number):
    if number % i == 0:
    isPrime = False
    if isPrime:
    print(f'{number} is a prime number.')
    else:
    print(f'{number} is not a prime number.')

    • @ismailnijazi7991
      @ismailnijazi7991 Год назад +1

      Lets take 100 as example in your solution we have to loop from 2 to 99 but in the videos solution we will loop from 1 to 10 which is 10 time faster. It is a math rule that says if a number is not divisble by 1 to squre(number) that number is prime number

    • @memy4460
      @memy4460 Год назад +1

      @@ismailnijazi7991 OMG, of course. I am an idiot. You are right, this is much faster. Sometimes i wonder if I don't have these ideas, can i still be a good programmer? Thanks for the explanation, much appreciated! I subbed to your channel.