Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions JAVA/Fibonacci.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import java.util.*;
import java.math.BigInteger;

public class Fibonacci {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print("Enter N (number of terms): ");
int n = sc.nextInt();

if (n <= 0) {
System.out.println("No terms to display.");
return;
}


BigInteger a = BigInteger.ZERO; // F0
BigInteger b = BigInteger.ONE; // F1


StringBuilder out = new StringBuilder();

for (int i = 1; i <= n; i++) {
out.append(a);
if(i < n) out.append(" ");
BigInteger next = a.add(b); // next = a + b
a = b;
b = next;
}

System.out.println(out.toString());
}
}
18 changes: 18 additions & 0 deletions JAVA/Palindrome.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import java.util.Scanner;

public class Palindrome {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.print("Enter a string: ");
String input = sc.nextLine();

// Normalize (ignore case and spaces)
String str = input.replaceAll("\\s+", "").toLowerCase();
String reversed = new StringBuilder(str).reverse().toString();

if (str.equals(reversed))
System.out.println("✅ '" + input + "' is a palindrome.");
else
System.out.println("❌ '" + input + "' is not a palindrome.");
}
}