November 4th, 2018, 06:04 AM  #1 
Member Joined: Oct 2017 From: Rumba Posts: 36 Thanks: 0  Algorithm question
Please someone check if my solution is right for (a)? http://prntscr.com/le8szd a) The mystery function basically finds the sum of digits in a number x. For ex., It works like initially Lets say x=123 So, Initially sum=0 So, Since x is not zero so it will enter loop So, sum=sum+123%10=3 Then x will be int(x/10)=12 So, it will go on and sum=3+2+1 Then x will become 0 and quit the loop and function will return the sum which is the sum of digits 

Tags 
algorithm, question 
Thread Tools  
Display Modes  

Similar Threads  
Thread  Thread Starter  Forum  Replies  Last Post 
Algorithm for PI  Learner  Applied Math  22  July 31st, 2013 07:05 AM 
Algorithm question  geliot  Computer Science  1  March 11th, 2012 01:59 PM 
GCD algorithm  Bogauss  Number Theory  14  March 1st, 2012 04:23 PM 
Prime Numbers Sum Algorithm Question  kokozko  Number Theory  1  November 30th, 2011 08:53 AM 
What algorithm  mmx64  Algebra  0  July 2nd, 2008 12:23 AM 