Basic algorithm of C language 21-reversible prime number

Source: Internet
Author: User

/*
==================================================================
Title: The reversible Prime is a number is a prime, reverse order or prime, such as ABC is prime, CBA is also prime.
==================================================================
*/
#include <stdio.h>
int Sushu (int n)
{
int i,k;
if (n%2==0)
return 0;
Else
{
K=int (N/2);
for (i=3;i<=k;i++)
{
if (n%i==0) return 0;
else return 1;
}
}
}
Main ()
{
int m,n,k=0;
int Ge,shi,bai,qian;
for (m=1000;m<10000;m++)
if (Sushu (m))
{
ge=m%10;
shi=m/10%10;
bai=m/100%10;
qian=m/1000;
N=ge*1000+shi*100+bai*10+qian;
if (Sushu (n))
{
printf ("%5d", m);
k++;
if (k%10==0)
printf ("\ n");
}


}
}


/*
==================================================================

Comment: Because the scope is relatively small (1000-10000), so the most direct method (intuitive) to seek, when the number

Larger time should be used two functions: 1 is to determine the number of prime functions, 2 is to find the reverse function, the reader can try to complete their own.

==================================================================
*/






Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Basic algorithm of C language 21-reversible prime number

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.