Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок0
Plz check whether my logic is correct or not??? question is check whether the number is fascinating number or not
Multiplying a number by two and three separately, the number obtained by writing the results obtained with the given number will be called a fascinating number. If the result obtained after concatenation contains all digits from 1 to 9, exactly once. Ex 192......... when 192*1+192*2+192*3=192384576 .. all no.s are occurring only once. https://code.sololearn.com/clJS0kcd7TVM/?ref=app
2 ответов
+ 1
In your loop part logic not work.
it only works for 1 iteration.
in loop, take i as char (not int), from '1' to '9' and compare i==ch.charAt(j) , if yes increment a count. No need of else part.
If count==9 then print fascinate else not. Before this , remove duplicates from final String..
In your program, a.toString(a) is wrong , it should be Integer.toString(a);
Your else part have return 1 and if part have break statement so it only work for 1 iteration..
Try again and check it with main method.. For any other, . . post a reply...
Hope it helps..
+ 2
I think your logic is correct but the program is not proper. There is no main method and it looks like incompleted.
Here check this
https://code.sololearn.com/cf2Bpjh3h5bO/?ref=app
I'm not very much familiar with java built-in methods so it'll be more numeric.