next up previous
Next: About this document ... Up: Challenge CS Problems Previous: Chapter 3.

Chapter 4.

1.
For a positive integer M define the following transformation. Write M as a binary number, then read the resulting sequence of 1s and in the opposite direction, and take the decimal number with that binary representation for the result of our operation. For instance, take decimal M = 25 = "11001". Then its binary represenation "11001" read the other way is "10011" = 19, so we have  25 -> 19 .

Print out the results of this operation for


M= 512, 513, 514, ... , 1024.

Here is how the output begins:  1, 513, 257 , .

2.
A positive integer is called perfect if the sum of all its divisors (including 1 but exluding the number itself) is equal to that number. Input a positive integer M and print out all perfect numbers less than M.

Example: The first two perfect numbers are 6 ( 6 = 1 +2 +3) and 28 ( 28 = 1 + 2 + 4 + 7 + 14 ). Perfect numbers are rare -- there are no other perfect numbers less than 100 and only one more less that 1000.



Sergey Bratus
12/8/1997