PlaidOA #1
Alternating Sum of Digits
Estimated EasyStatement and editorial — judging is being prepared
Topics (AI-labelled)Bits & MathStrings
Given an integer n, your task is to calculate the alternating sum of its digits. In other words, add up all the digits, taking the first digit with a positive sign, the second digit with a negative sign, the third digit with a positive sign, etc.
n = 521314→5 - 2 + 1 - 3 + 1 - 4 = -2n = 12134→1n = 104956→-5
Editorial
Loading solution…