#P0028. 简单校验和checksum

简单校验和checksum

1. Description

Code a function calculate_checksum, which takes a series of integers as input and returns their checksum value.

The way we calculate checksum is:

  • Add all the numbers
  • Calculate the residual of the sum divided by 1000

For example, if the input is "123 456 789", the checksum is

(123+456+789)%1000=368(123 + 456 + 789) \% 1000 = 368

2. Input & Output

Input:

  • A series of integers separated by space
  • Use input() as input. Notice that the value you get from input() is a string

Output:

  • An integer
  • Use print() for your output

Example

# Input: 
123 456 789
# Output: 
368