## CS13002 Programming and Data Structures | ## Section: 4/D, Spring 2005 |

## Assignment 2

Write a program to determine the two positive integers with properties described below:

Part IFind the smallest positive integer n with the following property. Let

n = abe the decimal expansion of n with_{k}a_{k-1}...a_{1}a_{0}a. Look at the integer_{k}> 0n(the cyclic right shift of n). The desired property of_{r}= a_{0}a_{k}a_{k-1}...a_{2}a_{1}nis thatnmust be a_{r}properintegral multiple of n. Also report the multipliern._{r}/n

Part IIFind the smallest positive integer n with the following property. Let

n = abe the decimal expansion of n with_{k}a_{k-1}...a_{1}a_{0}a. Look at the integer_{k}> 0n(the cyclic left shift of n). The desired property of_{l}= a_{k-1}a_{k-2}...a_{1}a_{0}a_{k}nis thatnmust be a_{l}properintegral multiple of n. Also report the multipliern._{l}/n

Note:Write a single program. Use integer arithmetic only. Since integers cannot be arbitrarily large in C, report "failure" if your program fails to locate the desired value(s) of n after checking all n <= 10^{9}. There is no need to use arrays for solving this assignment. However, there is no penalty if you use them.b is called a

propermultiple of a, if b = ka for some integer k > 1.