View Single Post
Old Jun 14th, 2004, 1:10 PM   #4
mesbaba8
Newbie
 
Join Date: Apr 2004
Posts: 1
Rep Power: 0 mesbaba8 is on a distinguished road
i will only give the algorithm, you try the code. There are two steps:

i) Last two digits should be 00 , so if it is >50 round to next hundred, and vica versa.

ii) sum all the digits of the new number, and continue this till you get one digit number (its easy with a recursive function). If the last digit, is divisible by 3, then it is ok, if not increase or decrease the hundred digit by one.

for example, take your number : 2527254

i) since last 2 digits > 50, round to 2527300

ii) sum of the digits = 19
sum of the digits = 10
sum of the digits = 1

then you will decrease the hundred digit by one.

so the final number is 2527200

not too diffucult to code
good luck
mesbaba8 is offline   Reply With Quote