Ask Question
20 October, 06:59

Sheldon Cooper's (of Big Bang Theory) favorite number is 73. One of his reasons is that 73 is a prime number and there are 21 prime numbers between 1 and 73. A prime number is a number greater than 1 that is not divisible by another number (the only even number that is a prime number is 2; all other prime numbers are odd). Write the Python code to calculate and print the prime numbers between 1 and 73 (but not including 73). Your program will also need to count the prime numbers to see if this is really the 21th prime number.

+3
Answers (1)
  1. 20 October, 08:40
    0
    Following is the code as required:

    print ("2 is the level 1 prime number")

    prime_count=1

    end=73

    for i in range (3, end):

    not_prime=0

    for j in range (2, i):

    if (i%j==0):

    not_prime=not_prime+1

    break

    if (not_prime==0):

    prime_count=prime_count+1

    print ("", i" is the level ", prime_count," prime number)

    print ()

    print (" Total number of prime numbers between 1, 73 is ", prime_count,"")

    Explanation:

    First of all 2 will be listed as the first prime number between 1 and 73. Total number of prime numbers will be stored in the variable prime_count. end variable will declare the upper bound as 73. First for loop having range from 3 to 73 will simply take each integer and send it to the second for loop to check for prime number. Second for loop having range from 2 to the integer i (lower bound of first loop) will check for prime numbers by dividing each integer "i" with that of "j", checking that it divides completely (giving remainder 0) or not. If the number "i" will not a prime number (if remainder = 0), it will increase the variable not_prime = 0 by 1 each time. When "i" will be a prime number it will make prime_count increase by 1 each time. print statement will be used to display each prime number with its level/rank. Total number of prime numbers between 1 and 73 will be given by the variable prime_count.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “Sheldon Cooper's (of Big Bang Theory) favorite number is 73. One of his reasons is that 73 is a prime number and there are 21 prime numbers ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers