Home » Ask & Discuss » Board Exams - CBSE, ICSE, State Boards » Computer Science « Back to Discussion
Computer Science
Find the first two primes above 1 million, which digit sums are also prime.
The solution is the con
None
Find the first two primes above 1 million, which digit sums are also prime.The solution is the concatination of the two numbers,Example: If the first number is 1,234,567and the second is 2,345,678,your solution is 12345672345678












I am using the fact that prime numbers can only be of the form 6k+1 or 6k+5.
Program :
n=1000000;
count1=0;
while(count1<2)
{
count2=0;
if(n%6==1 || n%6==5)
{
for(i=2;i<=sqrt(n);i++)
{
if(n%i==0)
count2=count2+1;
}
if(count2==0)
{
count1=count1+1;
printf("%d",n);
}
n=n+1;
}
else
n=n+1;
}