public class Pi {

public static void main(String[] args) {

int max = 1_000_000;

int increment = max / 8;

long startTime = System.currentTimeMillis();

//int stopTime = System.currentTimeMillis() – startTime;

int counter = 0;

while (counter <= max) { String s = ""; for (int i = 0; i < counter; i++) { s += "0"; } if (s.equals(reverse(s))) { System.out.println(counter + "/" + max); } else { if (counter % increment == 0) { // Print every 8th number. This is just for debugging purposes, and you can remove this in your own code if you want. System.out.println(counter); // This line outputs the current number we're trying to reverse to see if it's a palindrome or not. You can comment this out or delete it if you want, but I like to leave it in for debugging purposes because it helps me get a feel for where my program is import java.io.*; import java.util.ArrayList; import java.util.Random; public class Main { static int n; static int[] a; static int[] b; static ArrayList arr = new ArrayList();

static Random r = new Random();

public static void main(String[] args) throws IOException {

n = Integer.parseInt(args[0]);

a = new int[n];

b = new int[n];

for (int i = 0; i < n; i++) { a[i] = r.nextInt(10); b[i] = r.nextInt(10); arr.add(a[i]);arr.add(b[i]); if (i != 0) { // not the first digit of pi, so we need to insert a comma or period into the current digit, as appropriate for its place in pi's decimal expansion if (i == 1) arr.add(1); // decimal point before second digit of pi: 3.,1415... else if ( public static void main(String[] args) { int j; for(j=1;j<10;j++) { System.out.print(""+j); if(j==9) { break; }else { System.out.print(" "); } }//end for loop for one side of Pi System.out.print(" 3.");//Print the decimal point after the 1st digit of Pi. //count from 0 to 9,999,999 while also checking if it is a palindrome or not. int palindromeCheck = 0;//counter for while loop while(palindromeCheck < 9999999)//will run through 9999999 numbers and see if it's a palindrome or not and then print it out if it is a palindrome. { //convert integer to string String integerToString = Integer.toString(palindromeCheck);//convert palindromeCheck (int) to (string) so we can check if it is a palindrome or not public class Palindrome { public static void main (String[] args) { int x = 999; int y = 999; int largest = 0; Boolean found = false; while (x>100 && y>100) {

if (isPalindrome(x*y)) {

largest = x*y;

found = true;

break;

} else if (x%11==0){ // if x is divisible by 11, no need to check all of the combinations. Only those that are divisible by 11 and vice versa. This optimizes the program to run faster.

y–; // move down to the next number.

} else { // otherwise check all of the combinations until we find the lowest number that is a palindrome. Then move down 1, and repeat.

x–; // move left to the previous number.

}

}

System.out.println(“The largest palindrome is: ” + largest); // output our result! } public static Boolean isPalindrome(int n) { // method to determine whether or not a number is a palindrome int i=0,j=0,k=0;

public class Palindrome

{

public static void main(String[] args) {

String str;

int len, i, palindrome, count = 0;

boolean isPalindrome = false;

//Read the string from the keyboard

System.out.print(“Enter any string : “);

str = new Scanner(System.in).nextLine();

//Convert the string into lowercase

str = str.toLowerCase();

//Remove all whitespaces from the string

str = str.replaceAll(“\\s”, “”);

//Find the length of the string

len = str.length();

for (i = 0; i < len; i++) { palindrome = 1; for (int j = 0; j < len/2 && palindrome == 1; j++) { if (str.charAt(i+j) != str.charAt(len-1-j)) { palindrome = 0; } else { palindrome = 1; } if (palindrome == 1) { import java.util.*; import java.lang.*; import java.io.*; class Ideone { public static void main (String[] args) throws java.lang.Exception { // your code goes here Scanner in=new Scanner(System.in); int n=in.nextInt(); int a[]=new int[n]; for(int i=0;i

Tomy

Tomy is a contributor at AskMeCode. We are committed to providing well-researched, accurate, and valuable content to our readers.

You May Also Like

How To Use PIP to Install Python Packages on Windows

How To Use PIP to Install Python Packages on Windows

How To Use PIP to Install Python Packages on Windows: A blog about how you can use pip to help...

Hello World – What is Linux and how can I use it with Visual Studio Code? A blog around linux and visual studio code

Hello World – What is Linux and how can I use it with Visual Studio Code? A blog around linux and visual studio code

Hello World – What is Linux and how can I use it with Visual Studio Code? A blog around linux...

Whitehat Jr Review and Bonus - Is it a Scam?

Whitehat Jr Review and Bonus - Is it a Scam?

WhiteHat Jr is a platform that teaches coding for kids. White hat jr offers courses in coding for kids aged...

Artistic representation for How to Choose Coding Tutorials: Expert Guide

How to Choose Coding Tutorials: Expert Guide

How to Choose Coding Tutorials That Align With Your Sustainable Living Goals Coding has become an essential skill in our...

Leave a Reply

About | Contact | Privacy Policy | Terms of Service | Disclaimer | Cookie Policy
© 2026 AskMeCode. All rights reserved.