Lychrel sayı programını yapmaya çalışıyorum. ama yapamam. Kriterler, 10000'de Lychrel Numarası kontrol iterasyonunun sınırlı olarak listelenmesidir. Ben 30 olarak ayarlanmıştım.Ama çözüm henüz yoktu. Kontrole 30 ite kadar tamamlandığında numarası listelenmelidir. Çözümleri almadım.Lychrel Numarası Program Hatası
public class LychrelNumber {
static final int MAX_NUMBER = 10000;
static final int MAX_ITERATION = 30;
int iterationCount = 0;
void listTheLychrelNymber() throws Exception {
long i = 0;
long temp;
for (int j = 0; j < MAX_NUMBER; j++) {
iterationCount = 0;
temp = j;
for (i = 0; i < MAX_ITERATION; i++) {
long first = temp;
long second = reverseTheNumber(temp);
long third = first + second;
long fourth = reverseTheNumber(third);
if (third == fourth) {
break;
} else {
temp = third;
if (i == MAX_ITERATION) {
System.out.println("Lychrel Numbers are :" + j);
}
}
}
}
}
long reverseTheNumber(long n) {
long reverse = 0;
while (n != 0) {
reverse = reverse * 10;
reverse = reverse + n % 10;
n = n/10;
}
return reverse;
}
public static void main(String[] args) {
try {
LychrelNumber lychrelNumber = new LychrelNumber();
lychrelNumber.listTheLychrelNymber();
} catch (Exception e) {
}
}
}
bu SUCCESSFULL inşa edilir. ama çıktı almadım. i Döngünüzden en
downvoter kendimi geliştirmek için yorum eklemek yeterli. – Noorul