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&&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