"Ending" twin prime

Source: Internet
Author: User

Title Description

If both N and n+2 are prime numbers, they are called twin primes. Input m, output two numbers without exceeding m maximum twin primes. 5≤m≤10000.

Input requirements

Enter a positive integer m

Output requirements

The maximum number of twins for which the output two numbers do not exceed M

If the input
20
should be output
17,19
1#include <stdio.h>2 intIszhishu (intm)3 {4      for(intI=2; i<=m/2; i++)5     if(m%i==0) 6     {7         return 0;8          Break;9     }Ten     return 1; One } A intMain () - { -     intN,i,a=0, b=0; thescanf"%d",&n); -      for(i=n;i>1; i--) -     if(Iszhishu (i) = =1) -     { +A=b; -b=i; +         if(a-b==2) A         { atprintf"%d,%d\n", b,a); -              Break; -         } -     } -     return 0;  -}

"Ending" twin prime

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.