Traditional Culture Encyclopedia - Traditional stories - Judge whether a number n can be divisible by 3 and 5 at the same time. An algorithm for expressing problems with traditional processes
Judge whether a number n can be divisible by 3 and 5 at the same time. An algorithm for expressing problems with traditional processes
A number divisible by 5. The last digit is 0 or 5.
= => A number divisible by 3 and 5 at the same time. The sum of each number is a multiple of 3, and the last digit is 0 or 5.
Or more simply, it can be divisible by 15.
Algorithm:
1, to determine whether it is a multiple of 3.
-take it apart
Add up all the numbers and divide by 3.
-Remainder ==0?
Yes, go to the next step; No, the exit number
2. Judge whether the last digit is 0 or 5.
—— Is the last digit ==0 or ==5?
——————— Yes, exit is; No, the exit number
or
1, and judge whether it is a multiple of 15.
———n N is the remainder of 15.
-Remainder ==0?
——————— Yes, exit is; No, the exit number
Procedure:
# Including
empty
Master ()
{
Internationalorganizations (same as international organizations)
I,m,k= 10,s = 0;
Internationalorganizations (same as international organizations)
a[ 10];
Printf ("Enter a positive integer:");
scanf("%d ",& ampm);
a[0]= 0;
for(I = 1; I< 10; i++)
{ a[I]=(m-s)% k; k * = 10; s+= a[I]; }
If (s%3==0)
{if (a [1] = || a [1] = = 5) printf ("\ nm can be divisible by both 3 and 5 \ n");
other
Printf("\nm cannot be divisible by 3 and 5 at the same time \ n ");
}
other
Printf("\nm cannot be divisible by 3 and 5 at the same time \ n ");
}
- Previous article:What is the unit of TV Department?
- Next article:Lanxi Yufuyang harbor fun
- Related articles
- Baoying's 400-word Spring Festival composition
- Kindergarten can carry out what the Mid-Autumn Festival activities
- Do you know Chinese characters? Do you have any good literacy methods or literacy-related stories? Please tell us about Chinese characters and then write them down and share them with everyone.
- What are some of the hilarious sayings about the blind man?
- What's delicious about Tongchuan cuisine?
- Cartoon animation series illustrations —— How to construct cartoon figure painting?
- Brief score of theme song of traditional musical instruments
- Manuscript style template
- The black money means of individual doctors in hospitals
- Do you think there are more or less high-quality content in the new media era?