Problem of the Day
A new programming or logic puzzle every Mon-Fri

Mobile 6

Today's goal is to try and find an integer where the digit in the ones column is a 6 and when the 6 is moved to the front of the number, the number becomes 4 times the value of the starting number.

Permalink: http://problemotd.com/problem/mobile-6/

Comments:

  • Anonymous - 9 years, 9 months ago

    153846

    reply permalink

  • Jt - 9 years, 9 months ago

    bash 153,846

    #!/bin/bash
    counter=6
    
    while [ $counter -lt 1000000 ]; do
        if [[ ${counter:${#counter}-1:1} == '6' ]]
        then
          mult=$(($counter * 4))
          if [[ $mult == 6${counter:0:${#counter}-1} ]]
          then
            echo $counter $mult 6${counter:0:${#counter}-1}
            exit
          fi
        fi 
    
        let counter=counter+10
    done
    

    reply permalink

  • Kocsen - 9 years, 9 months ago

    def mobile():
        LIMIT = 999999
        for number in range(6, LIMIT, 10):
            num_str = str(number)
            intified = int("6" + num_str[:-1])
            if intified == number * 4:
                print("Seems like we found it!")
                print(num_str)
                break
    
    
    
    if __name__ == "__main__":
        mobile()
    

    reply permalink

  • Anonymous - 9 years, 9 months ago

    in java, i tried to calculate without using string

    static private void  runThis(){
    
        final int theMover = 6;
        final int theMultiplier = 4;
    
        for (int i = 1; i < 1000000; i++) {
            if (i % 10 == theMover) {
    
                // 6 * 10 power of x + remainder of 'i' 
                int j = theMover * (int) Math.pow(10, (int) Math.log10(i)) + (int) Math.floor(i / 10);
                if (i * theMultiplier == j) {
                    log.info("moving " + theMover + " across \t\t " + i + " * " + theMultiplier + " = " + j);
                    break;
                }
            }
        }
    }
    

    reply permalink

Content curated by @MaxBurstein