Figure this riddle out

77 Views Asked by At

I'm thinking of a number. It is odd. It's between 1 and 100. It's higher than 20. It is smaller than the answer to 6 x 6. It is a multiple of 5. The sum of its digits is 7.

3

There are 3 best solutions below

0
On

Let the number be $x$.

It is higher than $20$ and smaller than $6\times6$, which means $20<x<36$.

It is a multiple of $5$, which means it is either $25$, $30$, or $35$.

The sum of its digits is $7$, which means it is $25$.


In Pyth, we write:

VS100I&&&>N20<N*6 6!%N5q7smidT`NN

Try it online!

How it works:

VS100I&&&>N20<N*6 6!%N5q7smidT`NN
VS100                              for N from 1 to 100:
     I&&&                              if .... and ..... and ............ and ............... then
         >N20                             N>20
             <N*6 6                                N<6*6
                   !%N5                                      (N mod 5)==0
                       q7smidT`N                                              sum_of_digit(N) == 7
                                N          print(N)
0
On

$25$.

By the way, this isn't the right place for these sort of questions. Try puzzling.SE

1
On

You can run the following program through coliru to brute force the answer:

#include <iostream>

int main()
{
    int x;
    for (x = 1;x <= 100;++x) // Between 1 and 100
    {
        if (x % 2 == 0) continue; // Not odd
        if (x < 20) continue; // Not higher than 20
        if (x > 6 * 6) continue; // Not less than the answer to 6*6
        if (x % 5 != 0) continue; // Not a multiple of 5
        if (x % 10 + x / 10 == 7) // Digits add up to 7
                break;
    }
    std::cout << x;
}