Maximum prime number

Source: Internet
Author: User

Topic content:

The 10 maximum prime numbers within n (n<=500) and their and their and their corresponding outputs, respectively, and each of the 10 maximum primes are obtained. The value of n requires input from the keyboard.

Requires 10 primes to be output in order from large to small .

Examples of program run results:

Input N (n<=500):

270

269 263 257 251 241 239 233 229 227 223

sum=2432

Enter a hint: "Input N (n<=500): \ n"

Input Format : "%d"

Output format:

Output format for 10 maximum primes:"%6d"

Output format for sum:"\nsum=%d\n"

time limit: 500ms memory limit: 32000kb
#include <stdio.h>intMain () {intN,i,a=0, sum=0; printf ("Input N (n<=500): \ n"); scanf ("%d",&N);  for(;n>0; n--)        {           for(i=2; i<n;i++)          {           if(n%i==0)           Break; if(i==n-1) {printf ("%6d", N); A++; Sum+=N; }          }        if(a==Ten) Break; } printf ("\nsum=%d\n", sum); return 0;}
View Code

Maximum 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.