Smallest Number

Level pending

What is the sum of the digits of the smallest number which when divided by 10 leaves 9 as remainder,when divided by 9 leaves 8 as remainder, when divided by 8 leaves 7 as remainder and so until when divided by 2 leaves a remainder of 1?


The answer is 17.

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

2 solutions

Jero Dungog
Mar 1, 2014

I did the solution using JAVA and here's my code:

public class smallestnumber {

public static void main(String[] args) {

    int divisor = 10;       //assigns the initial value of the divisor
    int remainder = 9;    //assigns the  initial value of the remainder
    int value = 19;    //initial value of the number divided with 10 which has a remainder of 9 (this is obvious)

    for(int c = divisor; c >= 2; c--){ // starts the loop from divisor of 10 down to 2

        value = checkValue(divisor, remainder, value); // calls a method which returns the answer for the current divisor
        divisor--; // decreases the divisor by one
        remainder--; // decreases the remainder by one
    } // end of loop
    System.out.println(value); // prints the final answer **just sum up all the digits** --2519 w/c is 17--
}

private static int checkValue(int divisor, int remainder, int value) { // start of the method which checks the answer if divisible by the divisor and has a remainder equal to the specified remainder

    int add = checkAdd(divisor); // checks the number to be added to the previous answer
    int val = value+add; // sums up the previous answer with the new added value;
    return(((value % divisor) != remainder)? checkValue(divisor, remainder, val): value); // if every condition is met, it returns the answer, else it continues to increment the value;
} // end of method

private static int checkAdd(int divisor) {// start of method for check how much to add

    int val = 1; // initial value
    for(int c = divisor; c <= 10; c++){// loops from the divisor up to 10

        if(divisor == 10) // if the divisor is equal to 10 then assign the value to the variable val
            val = 10;
        else            //else multiply the current divisor with the current value of the variable val
            val = val * c;
    }

    return (((divisor == 10)? val : (val/divisor)));// returns the final value of the variable val
}

}

The number must be in the form: N=RK-1,where R is the least common multiple of 2,3,4,5,6,7,8 and 9. K=1,2,3,4.... R=2520 N=2520-1: N=2519 Hence, the sum of digits is 2+5+1+9=17

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...