1.13.21

Source: Internet
Author: User

21: Maximum mass factor sequence

Describe

Any input two positive integers m, n (1 < m < n <= 5000), and sequentially outputs the maximum mass factor (including M and N) for each number between M and N, and if a number itself is a prime number, the output is itself.

Enter a row that contains two positive integers m and n, with a single space interval. Output a row, the maximum quality factor for each integer, with a comma interval. Sample input

5 10

Sample output

5,3,7,2,3,5

SOURCE Yuanpei-from WHF

1#include <bits/stdc++.h>2 using namespacestd;3 intb;4 BOOLssintN)5 {6     if(n==2)return true;7      for(intI=2; I<=sqrt (n); i++)8         if(n%i==0)return false;9     return true;Ten } One voidJintN) A { -      for(intI=1; i<=n;i++) -     { the         if(n%i==0&AMP;&AMP;SS (n/i) = =true)  -         { -printf"%d", n/i); -             if(n!=b) printf (","); +             return; -         } +     } A } at intMain () - { -scanf"%d%d",&a,&b); -      for(inti=a;i<=b;i++) - J (i); -     return 0; in}

1.13.21

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.