Assignment 2

**[The year Y2K3]**Find the smallest positive integer t such that the decimal expansion of 2

^{t}starts with 2003, that is,2

that is, the four most significant decimal digits of 2^{t}= 2003`...`,^{t}are 2003.

**Note:**For example 2^{16}written in decimal is 65536. This expansion starts with 65, 655 etc. Your 2^{t}should start with 2003 and may be followed by any number of other digits.**Hint:**2^{t}satisfies the stated property if and only if2003 * 10

for some non-negative integer k. Now take logarithm to the base 10 and concentrate on the fractional parts.^{k}<= 2^{t}< 2004 * 10^{k}

**[Primes in base seven]**Write functions to perform the following tasks:

- Check if a positive integer (provided as parameter) is prime.
- Check if a positive integer (provided as parameter) is composite.
- Return the sum S
_{7}(n) of the 7-ary digits of a positive integer n (supplied as parameter).

Use the above functions to find out the smallest positive integer i for which S_{7}( p_{i}) is composite, where p_{i}is the i-th prime. Also print the prime p_{i}.

**Note:**1 is neither prime nor composite. The sequence of primes is denoted by p_{1}=2, p_{2}=3, p_{3}=5, p_{4}=7, p_{5}=11,`...`.

As an illustratuve example for this exercise consider the 31st prime p_{31}= 127 that expands in base 7 as127 = 2 * 7

i.e., the 7-ary expansion of 127 is 241 and therefore^{2}+ 4 * 7 + 1,S

which is prime._{7}(127)=2+4+1=7,

[Course home] [Home]