Question

Goldbach's Conjecture Python Loop through integers 4 through 100 for each number show two prime that...

Goldbach's Conjecture Python

Loop through integers 4 through 100

for each number show two prime that sum up to integer

b)Show with  comments  how you found the prime numbers that add up to make each integer from the range 4 to 100

Example output:

4 = 2 + 2

6 = 3 + 3

etc.

Hint:You are finding the even numbers from 4 through a 100 and finding the two prime numbers that  add to make the integer and printing it out

like this

4 = 2 +2

6 = 3 + 3

8 = 3 + 5

and so on till you can gone through the range

Comment out code judiciously

0 0
Add a comment Improve this question Transcribed image text
Answer #1

#source code:

def pr(n): #it was used for the given number is prime or not

count=0

for i in range(1,n):

if(n%i==0):

count=count+1

if(count==1):

return True

return False

for k in range(4,100): #iterate 4 to 100

for i in range(2,100): #for first number

for j in range(2,100): #for second number

if(pr(i) and pr(j)):

if(i+j==k): #here made sum

print("{}={}+{}".format(k,i,j)) #here print the output

break

break

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 def pr(n): #it was used for the given number is prime or not count=0 for i in range(1,

#output:

user@user-Latitude-3490:-/Desktop$ python3.7 1.py 4=2+2 5=3+2 7=5+2 9=7+2 13=11+2 15=13+2 19=17+2 21=19+2 25=23+2 31=29+2 33=

#if you have any doubt or more information needed comment below..i will respond as possible as soon..thanks..

Add a comment
Know the answer?
Add Answer to:
Goldbach's Conjecture Python Loop through integers 4 through 100 for each number show two prime that...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • The Goldbach conjecture asserts that every even number is the sum of two prime numbers

    in PythonThe Goldbach conjecture asserts that every even number is the sum of two prime numbers. Write a program that gets a number from the user, checks to make sure that it is even, and then finds two prime numbers that add up to the number.

  • Using Python: A Prime number is an integer greater than 1 that cannot be formed by...

    Using Python: A Prime number is an integer greater than 1 that cannot be formed by multiplying two smaller integer other than 1 and itself. For example, 5 is prime because the only ways of writing it as a product, 1 × 5 or 5 × 1. In this question you will write a program that takes a sequence of integers from the user and display all the prime numbers contained in that sequence. We will separate this question in...

  • Is Prime Number In this program, you will be using C++ programming constructs, such as functions....

    Is Prime Number In this program, you will be using C++ programming constructs, such as functions. main.cpp Write a program that asks the user to enter a positive integer, and outputs a message indicating whether the integer is a prime number. If the user enters a negative integer, output an error message. isPrime Create a function called isPrime that contains one integer parameter, and returns a boolean result. If the integer input is a prime number, then this function returns...

  • USE PYTHON PLEASE Write a function called is prime which takes a single integer argument and...

    USE PYTHON PLEASE Write a function called is prime which takes a single integer argument and returns a single Boolean value representing whether the given argument is prime (True) or not (False). After writing the function, test it by using a loop to print out all the prime numbers from 1-100. To check your results, the prime numbers from 1-100 are: 2, 3, 5, 7, 11. 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67,...

  • Python Print integer numbers up to 100 (1, 2, 3, …..) using a while loop. Each...

    Python Print integer numbers up to 100 (1, 2, 3, …..) using a while loop. Each integer number takes a separate line.

  • In Python 5. Write a function named listComprehensionDivisors that has 3 integer inputs, N, n1, and...

    In Python 5. Write a function named listComprehensionDivisors that has 3 integer inputs, N, n1, and n2. Using a single list comprehension to make a list of all of the numbers in the range 1..N that are either divisible by n1 or n2, where n1 and n2 can be any positive integers. After creating the list, your code should print out the following 2 lines: “We are printing all numbers from 1 to that are divisible by or ” “These...

  • PLEASE HELP! python code Problem 4. Define the function pythagorian_coprimes (n=100) that prints all pairs of...

    PLEASE HELP! python code Problem 4. Define the function pythagorian_coprimes (n=100) that prints all pairs of positive integer numbers (a, b) such that c = a + b is also a whole number and 1 <c<n. Include only those triples that are co-prime (do not have any common divisors other than 1). For example, (3, 4, 5) is okay but (30, 40, 50) should be skipped. Help: As a starting example, examine the function pythagorian_triples that yields all triples. Modify...

  • PYTHON! The Sieve of Eratosthenes THANKS FOR HELP! A prime integer is any integer greater than...

    PYTHON! The Sieve of Eratosthenes THANKS FOR HELP! A prime integer is any integer greater than 1 that is evenly divisible only by itself and 1. The Sieve of Eratosthenes is a method of finding prime numbers. It operates as follows: Create a list with all elements initialized to 1 (true). List elements with prime indexes will remain 1. All other elements will eventually be set to zero. Starting with list element 2, every time a list element is found...

  • Prime Number Programing in C Note: The program is to be written using the bitwise operation....

    Prime Number Programing in C Note: The program is to be written using the bitwise operation. Use an integer array (not a Boolean array) and a bit length (for instance 32 bits). In this program you will write a C program to find all prime numbers less than 10,000. You should use 10,000 bits to correspond to the 10,000 integers under test. You should initially turn all bits on (off) and when a number is found that is not prime,...

  • IN PYTHON 1.Choose a positive integer 2. To get the next number in the sequence we...

    IN PYTHON 1.Choose a positive integer 2. To get the next number in the sequence we do the following: If the integer is odd, we multiply by 3 and add 1. If the integer is even, we divide by 2. It is hypothesized that the above sequence will always converge to the value of 1, regardless of any valid initial choice. This hypothesis is known as the Collatz Conjecture. For example, if we start at 5, the numbers generated by...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT