-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheuler4.html
47 lines (45 loc) · 1.44 KB
/
euler4.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<html>
<head>
<script type="text/javascript">
function isPalindrome(text)
{
text=String(text);
half_length=text.length/2;
half_length=Math.floor(half_length);
for(i=0;i<half_length;i++)
{
if(text.charAt(i)==text.charAt(text.length-i-1))
{
continue;
}
else
{
return false;
}
}
return true;
}
function findLargestPalindrome()
{
var highest=0;
var product;
var lower_limit=100;
var higher_limit=1000;
for(var i=lower_limit;i<higher_limit;i++)
{
for(var j=lower_limit;j<higher_limit;j++)
{
product=i*j;
if(isPalindrome(product) && product>highest)
{
highest=product;
}
}
}
alert("Largest palindrome made from the product of two 3 digit numbers is "+highest);
}
</script>
</head>
<body onload="findLargestPalindrome();">
</body>
</html>