(Question) In some Asian countries, 8 and 6 are considered lucky digits. Any number containing only 8s and 6s is considered lucky number, e.g. 6, 8, 66, 668, 88, 886 .... Nguyen is a student who likes mathematics very much. Nguyen likes lucky numbers but only of the form S = 8...86...6 where S has at least one digit and the number of 8s or 6s can be zero. Examples of S are 8, 88, 6, 66, 86, 886, 8866 ... Given a positive integer X (1 < X < 10 000), Nguyen wants to find the smallest lucky number S which has at most 200 digits and is divisible by X. Your task is to write a program to find that number for Nguyen. problem link: https://www.codechef.com/problems/P10 , http://www.spoj.com/problems/LUCKYNUM/ someone please provide the logic or the code asked 07 Feb '17, 20:04

Since you only asked for algo, I think this will be appropriate. Get back to me in case you need further help! EDIT: A more detailed solution provided here (PS: I found problem similar to SPOJ's Zero and One. I did not link you to solution of your problem, but solution of a similar problem which uses same algo. I hope it would help. In case it doesn't, get back to me, k?) answered 07 Feb '17, 20:15
