Prime Numbers - Programmers Heaven

Howdy, Stranger!

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

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Prime Numbers

superdanlsuperdanl Posts: 1Member
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

  • bpajkbpajk Posts: 156Member
    : 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.