• 1
    Input and Output Data
    • Tasks
  • 2
    Conditions
    • Tasks
  • 3
    For Loop
    • Tasks
  • 4
    Strings
    • Tasks
  • 5
    While Loop
    • Tasks
  • 6
    Lists
    • Tasks
  • 7
    Two-Dimensional Arrays
    • Tasks
  • 8
    Dictionaries
    • Tasks
  • 9
    Sets
    • Tasks
  • 10
    Functions and Recursion
    • Tasks
  • к

Lesson 10. Functions and recursion

Difficulty level:

Task«The sum of the numbers of the number»

💻 Python
There is a superstition in a telephone company: it is believed that a phone number brings good luck if the sum of all its digits is a multiple of 7. You need to write a program that helps clients find the sum of the digits of their phone number.
Write a recursive function sum_of_digits(n) that takes a positive integer and returns the sum of all its digits.

Input format

one is a positive number-the phone number without separators

Output format

one number-the sum of all numbers of the entered number

Example

Input

89261234567

Output

53

Hint

There will be no clue here, decide for yourself!

main.py
Test 1
Test 2
Test 3
Test 4
Test 5
Test 6
Test 7
Test 8
Test 9
Test 10
Developer’s solution

🎉 Congratulations! 🎉

You did an excellent job with the task! It was a challenging problem, but you found the correct solution. You are one step closer to mastering programming! Keep up the good work, because every stage you pass makes you even stronger.

AD

Advertisement

red-snake blue-snake green-snake

Running your code...

AI Helper

Hi! I am your programming assistant. Ask me anything about Python — I can explain functions, methods, and help you understand the current task!