Computer Science & EngineeringProblem Solving Lab →List Of Experiments

More on Numbers

Many students in some class or either might have been interested in Number theory as it is so much fun in solving those riddles.Here we present two problems to refresh your skills. Hope you will love them. And the difference is that you may not have learnt computer programming back then but you know some computer programming now, so you can use the computer and program the task.


Problem 1:

Given a positive integer there is an easy way to check whether this integer is divisible by 9 or not. This was very popular before your mod operator was invented. The solution is simple, if you add the digits of the number repeatedly and finally get 9, then the given number is divisible by 9, else it is not divisible by 9. For example,



Input Specification


Input contains a single positive integer(< 1010). Use long long for the number.



Output Specification


Output "YES" or "NO" (quotes for clarity) corresponding to whether the number in input is divisible by 9 or not.



Sample Input and Output


Input: 12101
Output: NO
Input: 9009
Output: YES




Problem 2:

A whole number is said to be CIRCULAR if, when you multiply the number by its units decimal digit, the result is the number with its decimal digits rotated to the right, where the units digit becoming its high-order digit. For example, 102564 is a circular number because of the multiplication:
102564
*4
-------
410256
-------








Input Specification


Input contains a single postive integer N(< 10).



Output Specification


Output must contain a smallest circular positive number whose units digit must be N.



Sample Input and Output


Input: 2
Output:105263157894736842
Input: 4
Output: 102564
Please note that result may not fit even in long long(64 bit integer).