• subscribe
May 23, 2006 12:00 AM

Logical Puzzle

SQL Server Pro
InstantDoc ID #49984

Solution to May's Puzzle: Basic Arithmetic
In last month's arithmetic-themed puzzle (submitted by Denis Gobo), you were given the integers 3, 4, 5, and 6, and the basic arithmetic operators: +, -, × , ÷, and parentheses. The challenge was to come up with an expression that evaluates to 28.You could use each number only once and each operator only once.

The secret is to generate a 7 out of 3, 5, and 6, then multiply it by 4.This puzzle is confusing because it's easy to generate 7 by using 4 (e.g., 3 + 4, 4 + 6 - 3, 5 + 6 - 4), but then you're missing the 4 for the final multiplication. After you realize you need to generate a 7, then multiply it by 4, you might come up with the expression (6 - 2) × (3 + 4), but this solution doesn't meet the puzzle's requirements because it uses parentheses twice. A valid solution is 4 x (5 + 6 ÷ 3).

June's Puzzle: Remainders
Special thanks to my father, Gabriel Ben-Gan, for this month's puzzle. Find the smallest integer (n) that would yield a remainder of i-1 when divided by i, for any i in the range 2 through 10.That is, n % 2 = 1, n % 3 = 2, n % 4 = 3, ..., n % 9 = 8, n % 10 = 9, in which the percent sign (%) signifies a T-SQL modulo operator.



ARTICLE TOOLS

Comments
  • TOBY
    6 years ago
    Jun 27, 2006

    It's 1 less than the LCM (Least Common Multiple) of the sequence. It makes sense if you think about it. You know the number is going to be one less than a multiple of each i. So you know that the number is going to be one less than the smallest number that is a multiple of all i. Thus one less than the LCM for the set of i.

    I am embarrassed to say that I worked this one backwards, though. Wrote a quick Perl script, noticed the pattern, and then the lightbulb. Which is why I'm a programmer . . .

    --Toby Ovod-Everett

You must log on before posting a comment.

Are you a new visitor? Register Here
  • SP1?
    I know there is a SP1 for SQL 2008 R2 available....and there is a "feature pack" as well... ...
  • SQL database mirroring
    I have SQL Server 2008 R2 Enterprise 64bit on Windows 2008 R2 Enterprise 64bit.  Each SQL Server has...
  • Dell Compellent Disk Drive
    Does anybody has experience with Dell Compellent Disk Drive? Basically, this system manages all disk...
  • Sql server performance tuning
    I need to find a tool that help me to optimize sql server,queries,improve the performance and solve ...