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

Numbers that are divisible by 7 but are not a multiple of 5

Divisibility by 5 is effortlessly dictated by checking the last digit in the number (475), and checking whether it is either 0 or 5. In the event that the last number is either 0 or 5, the whole number is separable by 5

In the event that the last digit in the number is 0, the outcome will be the excess digits increased by 2. For instance, the number 40 finishes in a zero (0), so take the excess digits (4) and multiply that by two (4 × 2 = 8). The outcome is equivalent to the consequence of 40 divided by 5(40/5 = 8).

In the event that the last digit in the number is 5, the outcome will be the excess digits increased by two (2), in addition to one (1). For instance, the number 125 closures in a 5, so take the leftover digits (12), multiply them by two (12 × 2 = 24), then, at that point add one (24 + 1 = 25). The outcome is equivalent to the aftereffect 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

What is the number divisible by 7 But not multiple by 5

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

Algorithm:

  1. Step1. start
  2. Step2. define display function
  3. def display(n1,n2):
  4. Step3. In for Loop, check the condition    i%7==0 and i%5!=0
  5. Step4. If the condition is a true print i value, Otherwise go to the next iteration.
  6. Step5. End
  7. What is the number divisible by 7?
  8. def display(n1,n2):
  9. for i in range(n1,n2+1):
  10. if(i%7==0 and i%5!=0):
  11. print(i)
  12. display(1000,2000)

What numbers are divisible by 7 but not multiple by 5

def display(n1, n2):
results = []
for i in range(1000, 2000+1):
if (i%7==0) and (i%5!=0):
results.append(i)
return results
n1 = 1000
n2 = 2000
print(display(n1,n2))

numbers that are divisible by 7

Output: Numbers divisible by 7 list but multiple by 5 list

“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:

Get Salesforce Answers

Pramod Kumar Yadav is from Janakpur Dham, Nepal. He was born on December 23, 1994, and has one elder brother and two elder sisters. He completed his education at various schools and colleges in Nepal and completed a degree in Computer Science Engineering from MITS in Andhra Pradesh, India. Pramod has worked as the owner of RC Educational Foundation Pvt Ltd, a teacher, and an Educational Consultant, and is currently working as an Engineer and Digital Marketer.



Leave a Comment