[Go to site: main page, start]

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

Java Programs

The document contains two Java programs: LargestPalindrome.java, which calculates the largest palindrome product of two 3-digit numbers, and FibonacciReverse.java, which generates and prints the Fibonacci sequence in reverse order. Each program is implemented in a separate file with its own main method and logic. The PDF includes the complete code for all programs.

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)
5 views1 page

Java Programs

The document contains two Java programs: LargestPalindrome.java, which calculates the largest palindrome product of two 3-digit numbers, and FibonacciReverse.java, which generates and prints the Fibonacci sequence in reverse order. Each program is implemented in a separate file with its own main method and logic. The PDF includes the complete code for all programs.

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