Advertisement
Guest User

Untitled

a guest
Sep 22nd, 2019
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.39 KB | None | 0 0
  1. package com.company;
  2.  
  3. public class Main {
  4.  
  5.     public static void main(String[] args) {
  6.  
  7.         for (int a = 1; a < 1000000; a++) {
  8.  
  9.             int a_array = a;
  10.  
  11.             String string_a = Integer.toString(a_array);
  12.             int length = string_a.length();
  13.  
  14.             int[] array = new int[string_a.length()];
  15.  
  16.             for (int i = 0; i < length; i++) {
  17.                 array[i] = a_array % 10;
  18.                 a_array /= 10;
  19.  
  20.             }
  21.             int a_reversed = 0;
  22.             for (int i = 0; i < array.length; i++) {
  23.                 a_reversed += array[length - 1 - i] * Math.pow(10, i);
  24.             }
  25.             if (a == a_reversed) {
  26.  
  27.                 int a2 = a;
  28.                 String BinaryString = Integer.toBinaryString(2a);
  29.                 int lengthBinary = BinaryString.length();
  30.                 char[] array_Binary = new char[lengthBinary];
  31.  
  32.  
  33.                 for (int i = 0; i < lengthBinary; i++){
  34.                     array_Binary[i] = BinaryString.charAt(i);
  35.  
  36.                 }
  37.                 String BinaryReversedString = "";
  38.                 for (int i = lengthBinary - 1; i >= 0; i--){
  39.                     BinaryReversedString += array[i];
  40.                 }
  41.                 System.out.println(BinaryReversedString);
  42.                     if(BinaryString.equals(BinaryReversedString)){
  43.  
  44.                 }
  45.             }
  46.         }
  47.     }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement