Digit sum

Take an integer input, take the digit sum until one digit is left.
123456789->45->9
3264438924656432->71->8

IN

123456789

OUT

9

IN

3264438924656432

OUT

8

IN

86091795777214198982302874082228117380720385924328887730971212579342203308879143943429746338049565724

OUT

7
Login to submit solution


5 symbols pyth
Mon Sep 19 06:03:59 2016 Sait2000
h%tQ9
5 symbols golfscript
Wed Nov 2 07:39:20 2016 Sait2000
~(9%)
9 symbols pyth
Tue Jul 19 21:20:14 2016 Samuel88
+%-Q1 9 1
20 symbols python2
Sun Feb 22 15:18:09 2015 z423x5c6
print(input()-1)%9+1
20 symbols python2
Sun Feb 22 15:22:27 2015 z423x5c6
print(input()-1)%9+1
20 symbols python2
Sun Feb 22 15:22:45 2015 PFischbeck
print(input()-1)%9+1
20 symbols python2
Sun Mar 22 21:12:35 2015 LLcoolNJ
print(input()-1)%9+1
21 symbols python2
Wed May 6 19:00:06 2015 zimpha
print(input()-1)%9+1
21 symbols bash
Tue Aug 16 22:38:54 2016 hidefromkgb
sed '/^1/c9
/1/c7
c8'
27 symbols python3
Sun Feb 22 15:18:57 2015 z423x5c6
print((int(input())-1)%9+1)
31 symbols bash
Mon Jul 25 07:52:47 2016 hidefromkgb
echo $[(`sed s/./\&+/g`-1)%9+1]
37 symbols perl
Fri Apr 24 00:38:09 2015 James Curtis-Smith
($t+=$_)%=9 for split ,<>;print $t||9
42 symbols haskell
Fri Mar 13 14:10:07 2015 YoshikuniJujo
main=interact$show.(+1).(`mod`9).pred.read
57 symbols python3
Wed Nov 25 15:44:02 2015 louietyj
x=int(input())
while x>10:x=sum(map(int,str(x)))
print(x)
59 symbols python2
Sun Feb 22 15:20:24 2015 PFischbeck
i=raw_input()
while len(i)>1:i=str(sum(map(int,i)))
print i
69 symbols python3
Wed Nov 25 15:37:34 2015 louietyj
x = int(input())
while x > 10:
    x = sum(map(int, str(x)))
print(x)

View all solutions