Cody

Problem 1164. Sum the Digits of a Number

Given an integer, sum the digits repeatedly until you end up with a single value less than 10.

For example, if you add the digits of the number 123456789, you get 1+2+3+4+5+6+7+8+9 = 45, and then 4+5 = 9

The input will be a string of digits. The output should be the scalar value of the repeated sum of digits.

Solution Stats

41.69% Correct | 58.31% Incorrect
Last solution submitted on Feb 19, 2017

Problem Comments

Tags

Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!