Write a program that computes an integer's checksum. To compute the checksum, break the integer into its constituent digits and, working from right to left, doubling every second digit. If the product results in a number with two digits, treat those two digits independently. Then, sum all the digits for the final checksum. For example, 1496 has a checksum of 21. We compute this by first breaking 1496 into constituents and doubling the ever second digit => 6, 18, 4, 2. Then, the individual digits are summed as 6 + (1 + 8) + 4 + 2 = 21.

Respuesta :

Answer:

def checksum(num):

   total = 0

   count = 0

   while num > 0:

       digit = num % 10

       count += 1

       if count % 2 == 0:

           digit *= 2

           while digit > 0:

               total += digit % 10

               digit //= 10

       else:

           total += digit

       num //= 10

   return total

   

num = int(input("Enter an integer: "))

print("Checksum:", checksum(num))

if there’s anything to amend, please let me know. thank you!