Find the number of five-digit numbers less than 40 000 in which the three-digit numbers formed by a consecutive digits are all divisible by either 17 or 23. Remember, zero cannot be the first digit in a three-digit number.
Please show grade 7 math work

Respuesta :

Answer:

Following are the code to this questiuon:

def fiv(y):#defining a method fiv that hold a parameter  

  x = str(y) #defining a variable x that convert the value y in string  

  return three(x[0:3]) and three(x[1:4]) and three(x[2:5])#use return keyword to call the method three  

def three(x): #defining a method three that hold x variable as a parameter

   y = int(x) #use y to convert x in integer

   return y>=100 and (y%17==0 or y%23==0) #use return that gives a value which is divisiable by 17 or 23  

print([y for y in range(10000,40000) if fiv(y)])#use print method to print value

Output:

Please find the attached file.

Step-by-step explanation:

In the above code, two methods "fiv and three" is declared that accepts one variable as a parameter, which can be defined as follows:

  • In the fiv method, an "x" variable is defined that covert the value into a string and use to call the three methods.
  • Inside the three methods, a y variable is declared, that convert the value into integer and use return keyword, that checks value is divisible by 17 or 23.
  • In the print method, it accepts the given value, which is passed in the loop to print the value.    
Ver imagen codiepienagoya
Q&A Education