Hundreds of thousands of training workers can be divided by 3, 5, and 7

Source: Internet
Author: User
2887: Number of divisible values by 3, 5, and 7
  • View
  • Submit
  • Statistics
  • Prompt
  • Question
Total time limit:
1000 ms
Memory limit:
65536kB
Description
Enter an integer to determine whether it can be divisible by 3, 5, 7, and output the following information:
1. It can be divisible by 3, 5, and 7 at the same time (3, 5, and 7 are output directly, with a space in the middle of each number );
2. It can be divided by two numbers (two numbers are output, smaller ones are in front and larger ones are in the back. Example: 3 5, 3 7, or 5 7, separated by spaces)
3. Can be divisible by one of the numbers (output this divisor)
4. It cannot be divisible by any number. (lowercase characters 'n' are output, excluding single quotation marks)
Input
A number
Output
A row of numbers, arranged in ascending order, including the divisor numbers 3, 5, and 7. The numbers are separated by spaces.
Sample Input
0515105
Sample output
3 5 753 53 5 7
 
#include<stdio.h>#include<stdlib.h>int main(){int n;while(scanf("%d",&n) != EOF){if(n%3==0 && n%5==0 && n%7==0){printf("%d %d %d\n",3,5,7);}else if(n%3==0 && n%5==0){printf("%d %d\n",3,5);}else if(n%5==0 && n%7==0){printf("%d %d\n",5,7);}else if(n%3==0 && n%7==0){printf("%d %d\n",3,7);}else if(n%3==0){printf("%d\n",3);}else if(n%5==0){printf("%d\n",5);}else if(n%7==0){printf("%d\n",7);}}return 0;}

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.