Prime Numbers

Hi,

I'm new to programming and am trying to write a couple programs but can't figure it out. The first one is a program to generate all the Prime Twin numbers less than 2000. The second one is a program for Goldbach's conjecture for even numbers to 200. Any help would be appreciated. Thanks

Comments

  • : Hi,
    :
    : I'm new to programming and am trying to write a couple programs but can't figure it out. The first one is a program to generate all the Prime Twin numbers less than 2000. The second one is a program for Goldbach's conjecture for even numbers to 200. Any help would be appreciated. Thanks
    :
    To calculate twin primes smaller than 2000 you nead to have a number x. The initial value of the number x is 2000. Then you need to decreas x to the number 3 (3 is the last twin pair). You check every number x between 3 and 2000 if it is a prime. You do that by mod-ing every number between x and 1, checking if all return the value 0 (if they do, then it is a prime). When the program finds the second prime you need to check if they are apart by 2. If they are a twin number is found.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion