- 2

pls write a program to input 2 nos. and tell whether they are twin primes or not... save it and tell me the code name I will have a look at it.

15th Jul 2016, 2:43 PM
Siddhant Saxena
Siddhant Saxena - avatar
7 ответов
+ 2
Again, this looks so much like a homework assignment... As a former educator in computer science it saddens me a little as someone might have wasted an opportunity to learn.
15th Jul 2016, 8:45 PM
Stefan
Stefan - avatar
+ 1
agreeing with Stefan here, I actually had a blast writing this code. It's a little over complicated, but that was part of the fun. nonetheless this http://www.sololearn.com/app/cplusplus/playground/cP6xY2cId5cv should give you a rough idea for an approach and teach a thing or two. feel free to modify/spruce it up, cheers!
16th Jul 2016, 12:26 PM
destro
0
twin primes?
15th Jul 2016, 2:44 PM
SIDDHARTH VASU
SIDDHARTH VASU - avatar
0
I tried it on my own but was not able to complete it
16th Jul 2016, 12:30 PM
Siddhant Saxena
Siddhant Saxena - avatar
0
thx sid and destro
16th Jul 2016, 12:31 PM
Siddhant Saxena
Siddhant Saxena - avatar
- 1
yes search on net what are twin primes..... they are 2 consecutive prime no's.
15th Jul 2016, 2:47 PM
Siddhant Saxena
Siddhant Saxena - avatar
- 1
bool twins = true; if(no1 == no2) twins = false; else if(isPrime(no1) && isPrime(no2)) { for(int i = min(no1, no2) + 1; i < max(no1, no2); ++i) { if(isPrime(i)) { twins = false; break; } } } else twins = false; cout << twins;
15th Jul 2016, 8:24 PM
this->getName()