Computer Science, asked by jhashreya707, 3 months ago

print all 2digit number where unit digit is a factor of 10th place digit e.g 21, 42,63 etc​

Answers

Answered by allysia
0

Language:

Python

Program:

for i in range(10,99):

   if i%10==0:

       continue

   else:

       a=i%10

       b=i//10

       if b%a==0:

           print(i)

Output:

Consider the attachment.

Logic:

  • Save last digit i.e  the remainder when 2-digit number is divided by 10 in a variable.
  • Save first digit i.e the quotient when 2-digit number is divided by 10.
  • Check if the last digit is 0. If yes skip since divisibility by 0 is undefined. As for example 10, 1/0 = undefined.
  • If no then check for divisibility of those variables as quotient / reminder

Attachments:

Attachments:
Similar questions