answersLogoWhite

0


Best Answer

/* emirp_1000.c j. adams

*

* Program to generate prime numbers that are emirps

*

*

* compile with $> gcc -o emirp_1000 emirp_1000.c -lm

*

*

*/

#include <stdio.h>

#include <string.h>

#include <stdlib.h>

#include <math.h>

#define MAX_RANGE 1000

int main(void)

{

int p = 11;

int p2 = 0;

int itr = 0;

int cnt = 0;

int rev = 0;

int skip_val[]= {2, 4, 2, 2, 2, 4, 2, 2, 2, 4, 2, 2, 2, 4, 2, 2};

while(p < MAX_RANGE)

{

cnt = 16;

itr = 0;

while(cnt--)

{

// check p for primeness.

if(isit_prime(p))

{

p2 = p;

// reverse p

while(p2 > 0)

{

rev = rev * 10 + (p2 % 10);

p2 = p2/10;

}

// If rev != p (palindrome) and rev is prime

if((rev ^ p)&&(isit_prime(rev)))

printf("\n%d", p);

}

rev = 0;

p = p += skip_val[itr++];

}

}

printf("\n");

return 0;

}

int isit_prime(int n)

{

int k = 0;

if (n 0)

return 0;

return 1;

}

User Avatar

Wiki User

11y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Write a C program to find all emirp numbers between 1 and 1000 1 and 1000 inclusive?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

How do you write a VBnet program to find the prime numbers between 100 to 200?

VBnet program to find the prime numbers between 100 to 200?


Q2 Write a program to print even numbers between 10 and 50?

You can use int i; for (i = 10; i &lt;= 50; i += 2) {//print i} as a program to print even numbers between 10 and 50.


What is the sum of the digits needed to write all the whole numbers from 0 to 10000 inclusive?

It is 180,001.


What are all the whole numbers between 1 to 1000000000?

All of the whole numbers between one and a billion. Honestly, we're not robots here. Write a program and do it yourself, if you really need them.


Write a program in Lex to eliminate white space and collect numbers as a token?

write a lex program to delete space from the program


How do you write an assembly language program to find the sum of n numbers using array?

write an assembly language program to find sum of N numbers


Shell program for gcd of three given numbers?

write a shell program for finding out gcd of three given numbers? write a shell program for finding out gcd of three given numbers? write a shell program for finding out gcd of three given numbers? check bellow link http://bashscript.blogspot.com/2009/08/gcd-of-more-than-two-numbers.html


How do you write a program in objective c numbers 1-100 prime numbers?

fdsgfhgdfhgdf


Could you Write a program for 8086 microprocessor that displays on the monitor the average of 2 numbers from an array?

How to write a program for mouse in microprocessor?


Write a program to print even and odd numbers in between 1 to 10?

for (int i = 2; i < 10; i ++) printf("%d\n", i); You did say even and odd numbers between 1 and 10. That's allnumbers between 1 and 10.


How to write a C program to find largest 2 numbers using pointers?

program to find maximum of two numbers using pointers


Write a Program in c to find palindrome numbers between any two numbers?

please somebody should help me answer this question..I have a project on it even! It seems almost impossible at the moment.