Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function euler5(){
- $x = 20;
- for ($y = 1; $y < 20; $y++) {
- if (!($x%$y)) {
- } else {
- $x+=20;
- $y = 1;
- }
- }echo $x;
- };
- <?php
- function gcd($a,$b) {
- while($a>0 && $b>0) {
- if($a>$b) $a=$a-$b; else $b=$b-$a;
- }
- if($a==0) return $b;
- return $a;
- }
- function euler5($i=20) {
- $euler=$x=1;
- while($x++<$i) {
- $euler*=$x/gcd($euler,$x);
- }
- return $euler;
- }
- ?>
- <?
- function eulerPuzzle()
- {
- $integers = array( 11,12,13,14,15,16,17,18,19 );
- for ($n = 20; 1; $n += 20 ) {
- foreach ($integers as $int) {
- if ( $n % $int ) {
- break;
- }
- if ( $int == 19 ) {
- die ("Result:" . $n);
- }
- }
- }
- }
- eulerPuzzle();
- ?>
- <?php
- $i=20;
- while ($i+=20) {
- for ($j=19;$j!==10;--$j){
- if ($i%$j) continue 2;
- }
- die ("result: $in");
- }
- puts 5*7*9*11*13*16*17*19
- function eulerPuzzle() {
- $integers = array (11, 12, 13, 14, 15, 16, 17, 18, 19 );
- for($n = 2520; 1; $n += 2520) {
- foreach ( $integers as $int ) {
- if ($n % $int) {
- break;
- }
- if ($int == 19) {
- die ( "Result:" . $n );
- }
- }
- }
- }
- eulerPuzzle ();
- #!/usr/bin/env python
- from operator import mul
- def factor(n):
- factors = {}
- i = 2
- while i < n and n != 1:
- while n % i == 0:
- try:
- factors[i] += 1
- except KeyError:
- factors[i] = 1
- n = n / i
- i += 1
- if n != 1:
- factors[n] = 1
- return factors
- base = {}
- for i in range(2, 2000):
- for f, n in factor(i).items():
- try:
- base[f] = max(base[f], n)
- except KeyError:
- base[f] = n
- print reduce(mul, [f**n for f, n in base.items()], 1)
Add Comment
Please, Sign In to add comment