Restructuring

This commit is contained in:
2024-07-01 13:49:44 +00:00
parent f11b705ef0
commit 8d60e1b905
194 changed files with 1296 additions and 112 deletions

View File

@ -0,0 +1,17 @@
title: Find the largest palindrome made from the product of two 3-digit numbers.
url: http://projecteuler.net/problem=4
desc: |
A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 99.
Find the largest palindrome made from the product of two 3-digit numbers.
solution: |
See code
solutions:
solve.php:
desc: Basic solution
language: php
solve.rb:
desc: Basic solution in Ruby
language: ruby

View File

@ -0,0 +1,13 @@
<?php
$max = 0;
for($num1 = 1000; $num1>100; $num1--) {
for($num2 = 1000; $num2>100; $num2--) {
$sum = $num1 * $num2;
//Check if palindrome
if($sum > $max AND strrev($sum) == $sum)
$max = $sum;
}
}
echo $max;

View File

@ -0,0 +1,10 @@
max = 0;
(100..1000).each do |num1|
(100..1000).each do |num2|
sum = num1 * num2
if( sum > max and sum.to_s.reverse == sum.to_s)
max = sum
end
end
end
print max