Skip to content

Instantly share code, notes, and snippets.

  • Select an option

  • Save Pyroarsonist/5c6e11263809462ae6c8 to your computer and use it in GitHub Desktop.

Select an option

Save Pyroarsonist/5c6e11263809462ae6c8 to your computer and use it in GitHub Desktop.
Lesson5lvl2b
package lvl2b;
public class Main
{
public static void main(String[] args)
{
System.out.print("Maximum polindrom like product from 2 3-numbered value is: ");
System.out.print(polindrom(999,999)[0]+" with this values: "+polindrom(999,999)[1]+" and "+polindrom(999,999)[2]);
}
static int backstab (int x) {
String s=Integer.toString(x);
String s1="";
for (int i=s.length()-1;i>=0;i--) {
s1+=s.substring(i,i+1);
}
int k=Integer.parseInt(s1);
return k;
}
static int[] polindrom (int a,int b) {
int r=0;
int m=0;
int n=0;
for (int i=100;i<=a;i++) {
for (int j=100;j<=b;j++) {
if (backstab(i*j)==(i*j)&&backstab(i*j)>r) {
r=i*j;
m=i;
n=j;
}
}
}
int []A={r,m,n};
return A;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment