My Math Forum  

Go Back   My Math Forum > Science Forums > Computer Science

Computer Science Computer Science Forum

LinkBack Thread Tools Display Modes
November 4th, 2018, 05:04 AM   #1
Joined: Oct 2017
From: Rumba

Posts: 39
Thanks: 0

Algorithm question

Please someone check if my solution is right for (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


Then x will become 0 and quit the loop and function will return the sum which is the sum of digits
sita is offline  

  My Math Forum > Science Forums > Computer Science

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 06:05 AM
Algorithm question geliot Computer Science 1 March 11th, 2012 12:59 PM
GCD algorithm Bogauss Number Theory 14 March 1st, 2012 03:23 PM
Prime Numbers Sum Algorithm Question kokozko Number Theory 1 November 30th, 2011 07:53 AM
What algorithm mmx64 Algebra 0 July 1st, 2008 11:23 PM

Copyright © 2019 My Math Forum. All rights reserved.