Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

Digit root

Posted by mlh at 2009-11-07 21:18:52 on Problem 1519
http://en.wikipedia.org/wiki/Digital_root
As S(n)=n-9 * ⌊n/9⌋
=>
S(n) mod 9 = n mod 9
And S(n) = (N1+N2+…Ni+…)  (Ni means the digit of n) 
=>  
dr(n)=n mod 9=S(n) mod 9=(N1+N2+…Ni+…) mod 9 (S(n) mod 9 ≠0), 
dr(n) = 9 (S(n) mod 9 = 0)
Then we can get the algorithm (n ≠0)
For Ni:N
	tmp = (Ni + tmp) mod 9
if tmp equals 0
	dr(n) = 9
else
	dr(n)=tmp

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator