Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Prime Numbers and Twin Primes in C...

Posted on 2003-02-25
6
Medium Priority
?
670 Views
Last Modified: 2011-10-03
Hi,

    I'm trying to write a program that calculates all of pairs of numbers in the range 1-400 in which the first number is any prime number, and the second is 2X the first number + 1, and is also prime, then prints each pair.  

     Does anybody know how this might be done?

Thanks!

--J.Pryce.
0
Comment
Question by:JohnPryce
6 Comments
 
LVL 6

Expert Comment

by:gj62
ID: 8018622
Yes, but it sounds like homework, which is against the house-rules to post solutions to.  If you make an attempt, we will certainly try to help you where you run into difficulty.  

That said, a google search on prime numbers source code usually will give you a fair starting point...
0
 
LVL 6

Expert Comment

by:gj62
ID: 8018634
You can also look under Sieve of Eratosthenes, but you probably knew that already...
0
 
LVL 1

Expert Comment

by:TheBeaver
ID: 8021716
If you ask me this is a trick question as any number that is 2X something is divisable by 2 and therefore NOT PRIME.

Then again, if you are saying...
second_number = (first_number * 2) + 1

...then the only result (if you think about it) would be 1 and 3. Wouldn't it?
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 85

Expert Comment

by:ozo
ID: 8022235
1 is not prime
but if we are saying
second_number = (first_number * 2) + 1
then there's 2 and 5, or 3 and 7, or 5 and 11,  etc
0
 
LVL 20

Expert Comment

by:jmcg
ID: 10018405
Nothing has happened on this question in over 10 months. It's time for cleanup!

My recommendation, which I will post in the Cleanup topic area, is to
delete, forfeit points [homework].

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

jmcg
EE Cleanup Volunteer
0
 

Accepted Solution

by:
SpazMODic earned 0 total points
ID: 10050507
PAQed - no points refunded (of 30)

SpazMODic
EE Moderator
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
Examines three attack vectors, specifically, the different types of malware used in malicious attacks, web application attacks, and finally, network based attacks.  Concludes by examining the means of securing and protecting critical systems and inf…
The goal of this video is to provide viewers with basic examples to understand opening and writing to files in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.
Suggested Courses

578 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question