# Display all such numbers which are divisible by 7 but are not a multiple of 5 between 1000 and 2000

## Display all such numbers which are divisible by 7 but are not a multiple of 5

Display all such numbers which are divisible by 7 but are not a multiple of 5 between 1000 and 2000.Divisibility by 5 is easily determined by checking the last digit in the number (475), and seeing if it is either 0 or 5. If the last number is either 0 or 5, the entire number is divisible by 5

If the last digit in the number is 0, then the result will be the remaining digits multiplied by 2. For example, the number 40 ends in a zero (0), so take the remaining digits (4) and multiply that by two (4 × 2 = 8). The result is the same as the result of 40 divided by 5(40/5 = 8).

If the last digit in the number is 5, then the result will be the remaining digits multiplied by two (2), plus one (1). For example, the number 125 ends in a 5, so take the remaining digits (12), multiply them by two (12 × 2 = 24), then add one (24 + 1 = 25). The result is the same as the result of 125 divided by 5 (125/5=25).

Example.
If the last digit is 0

110 (The original number)
11 0 (Take the last digit of the number, and check if it is 0 or 5)
11 0 (If it is 0, take the remaining digits, discarding the last)
11 × 2 = 22 (Multiply the result by 2)
110 ÷ 5 = 22 (The result is the same as the original number divided by 5

Write a program which makes use of function to display all such numbers which are divisible by 7 but are not a multiple of 5, between 1000 and 2000.

Aim: To display all such numbers which are divisible by 7 but are not a multiple of 5, between 1000 and 2000

Algorithm:

Step1. start

Step2. define display function

def display(n1,n2):

Step3. In for Loop, check the condition    i%7==0 and i%5!=0

Step4. If the condition is true print i value, Otherwise go to next iteration.

Step5. End

Program:

def display(n1,n2):

for i in range(n1,n2+1):

if(i%7==0 and i%5!=0):

print(i)

display(1000,2000)

Ouput

“C:\Program Files\Python37\python.exe” C:/Users/user/.PyCharmCE2019.2/config/scratches/scratch.py
112, 119, 126, 133, 147, 154, 161, 168, 182, 189, 196, 203, 217, 224, 231, 238, 252, 259, 266, 273, 287, 294, 301, 308, 322, 329, 336, 343, 357, 364, 371, 378, 392, 399, 406, 413, 427, 434, 441, 448, 462, 469, 476, 483, 497, 504, 511, 518, 532, 539, 546, 553, 567, 574, 581, 588, 602, 609, 616, 623, 637, 644, 651, 658, 672, 679, 686, 693, 707, 714, 721, 728, 742, 749, 756, 763, 777, 784, 791, 798, 812, 819, 826, 833, 847, 854, 861, 868, 882, 889, 896, 903, 917, 924, 931, 938, 952, 959, 966, 973, 987, 994,
Process finished with exit code 0

## Recommended Posts:

Display all such numbers which are divisible by 7 but are not a multiple of 5 between 1000 and 2000