0% found this document useful (0 votes)
2 views1 page

Java Programs

The document contains Java programs in separate files, including 'LargestPalindrome.java' which finds the largest palindrome made from the product of two 3-digit numbers, and 'FibonacciReverse.java' which generates the first 10 Fibonacci numbers and prints them in reverse order. Each program is fully implemented with necessary methods and logic. The document is a comprehensive collection of Java code examples.

Uploaded by

swetharaghu4311
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views1 page

Java Programs

The document contains Java programs in separate files, including 'LargestPalindrome.java' which finds the largest palindrome made from the product of two 3-digit numbers, and 'FibonacciReverse.java' which generates the first 10 Fibonacci numbers and prints them in reverse order. Each program is fully implemented with necessary methods and logic. The document is a comprehensive collection of Java code examples.

Uploaded by

swetharaghu4311
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Java Programs (Separate Files)

1. [Link]
-------------------------
public class LargestPalindrome {
public static void main(String[] args) {
int max = 0;

for (int i = 100; i <= 999; i++) {


for (int j = 100; j <= 999; j++) {
int num = i * j;
if (isPalindrome(num) && num > max) {
max = num;
}
}
}

[Link]("Largest Palindrome: " + max);


}

static boolean isPalindrome(int n) {


int temp = n, rev = 0;
while (temp > 0) {
rev = rev * 10 + temp % 10;
temp /= 10;
}
return n == rev;
}
}

2. [Link]
-------------------------
public class FibonacciReverse {
public static void main(String[] args) {
int n = 10;
int[] arr = new int[n];

int a = 0, b = 1, c;

for (int i = 0; i < n; i++) {


arr[i] = a;
c = a + b;
a = b;
b = c;
}

for (int i = n - 1; i >= 0; i--) {


[Link](arr[i] + " ");
}
}
}

... (Truncated in summary)


The PDF includes ALL programs fully.

You might also like