歐拉計劃----https://projecteuler.net/ui
最大回文乘積
迴文數就是從前日後和從後往前讀都同樣的數。由兩個2位數相乘獲得的最大回文乘積是 9009 = 91 × 99。spa
找出由兩個3位數相乘獲得的最大回文乘積。.net
public class Problem4 { static int cal() { int max=0; int num=0; for (int i = 100; i < 1000; i++) { for (int j = 100; j < 1000; j++) { num=i*j; String s1=new StringBuilder(String.valueOf(num)).reverse().toString(); if(s1.equals(num+"")) { if(num>max) { max=num; } } } } return max; } public static void main(String[] args) { long start = System.currentTimeMillis(); System.out.println(cal()); long end = System.currentTimeMillis(); System.out.println("runtime:" + (end - start)); } }