Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Let's see how good /prog/ really is

Name: Anonymous 2012-10-26 13:44

Can you find the smallest number that fulfills the following criteria?

1. It can only contain digits of 3, 5 and 7
2. The sum of the digits can be divided by 3, 5 and 7 without remainder
3. The number can be divided by 3, 5 and 7 without remainder

Name: Anonymous 2012-10-26 20:01

starting from 1...no way to fuck this one up


$test_number = 1;
$winner_found = false;
$seconds = 130;

do {
   
    $digit_test = true;
    $sum_test = true;
    $division_test = true;
   
    $char_array = str_split($test_number);
   
    foreach($char_array as $value) {
        if($value != 3 && $value != 5 && $value != 7) {
            $digit_test = false;
            break;
        }
    }
   
    if($digit_test == true) {
       
        $sum = array_sum($char_array);
        if($sum % 3 != 0 || $sum % 5 != 0 || $sum % 7 != 0 ) {
            $sum_test = false;
        }
       
        if($sum_test == true) {
            if($test_number % 3 != 0 || $test_number % 5 != 0 || $test_number % 7 != 0 ) {
                $division_test = false;
            }
        }
    }
   
   
    if($digit_test == true && $sum_test == true && $division_test == true) {
        $winner_found = true;
    } else {
        $test_number++;
        set_time_limit($seconds);
    }
    echo $test_number . "\r\n";

} while($winner_found == false);

echo "winner:" . $test_number;

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List