OnlineGDB: LINK. PythonOnline: LINK Online GDB Python Online…
OnlineGDB: LINK. PythonOnline: LINK Online GDB Python Online The additive persistence of a number is the number of steps required to reduce it to a single digit by repeatedly adding its digits together. For example, the additive persistence of 58 is 2 because: Step 1: 5 + 8 = 13 Step 2: 1 + 3 = 4 And since 4 is a single-digit number, we stop after 2 steps (additive persistence = 2). Write a function calculate_additive_persistence(num) that takes a positive integer as input and returns its additive persistence. Examples: calculate_additive_persistence(7) should return 0 (it’s already a single-digit number) calculate_additive_persistence(15) should return 1 (1+5=6) calculate_additive_persistence(195) should return 2 (1+9+5=15, 1+5=6) calculate_additive_persistence(9875) should return 3 (9+8+7+5=29, 2+9=11, 1+1=2) Your function should work for any positive integer.