https://ide.codingblocks.com/s/69457.sir In the code which I have is debug and get compiled but the output get wrong.
please help to solve this and also mark my mistake.
Regarding Finding CB NUMber
Sorry Sir This is my ide
Hi Raushan, there are 2 mistakes in your code. First that numbers you find and declare as CB numbers are overlapping sometimes. For ex in 5117, valid CB numbers are 5, 11, 7 but your program will count them as 5, 11, 17, 7. You need to fix this by maintaining a record in memory which tells wether a digit at a particular position has been used or not.
Secondly your condition to check wether the the number generated is a CB number or not should be judged in following steps:
- check if it is 1 or 0 if yes then its NOT a CB number.
- check if it is equal to any of {2, 3, 5, 7, 11, 13, 17, 19, 23, 29}. if yes it’s a CB no.
- if it is divisible by any of above nos. its is not a CB no. then
Pls correct these mistakes in your code.
Hey Raushan,
As you are not responding to this thread, I am marking your doubt as Resolved for now. Re-open it if required.
Please mark your doubts as resolved in your course’s “ Ask Doubt ” section, when your doubt is resolved.