This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| //http://odz.sakura.ne.jp/projecteuler/index.php?cmd=read&page=Problem%2021 | |
| //write kazua | |
| $y = array(); | |
| $f = function($num) { | |
| global $y; | |
| $d = array(); | |
| for ($i = 1; $i <= $num / 2; $i++) if ($num % $i == 0) $d[] = $i; | |
| $y[$num] = array_sum($d); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| //http://odz.sakura.ne.jp/projecteuler/index.php?cmd=read&page=Problem%2020 | |
| //write kazua | |
| function array_bcproduct($a) { | |
| $r = "1"; | |
| foreach ($a as $v) | |
| $r = bcmul($r, $v); | |
| return $r; | |
| } | |
| echo array_sum(str_split(array_bcproduct(range(1, 100)))); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| //array_bcproduct | |
| //write kazua | |
| //$a array | |
| function array_bcproduct($a) { | |
| $r = "1"; | |
| foreach ($a as $v) | |
| $r = bcmul($r, $v); | |
| return $r; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| //array_scanLeftとarray_scanRight | |
| //write kazua | |
| //$a array | |
| //$f callback | |
| //$i initial | |
| function array_scanLeft($a, $f, $i) { | |
| $r = array($i); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| //http://odz.sakura.ne.jp/projecteuler/index.php?cmd=read&page=Problem%2080 | |
| //write kazua | |
| echo | |
| array_sum( | |
| array_map( | |
| function ($value) { | |
| return | |
| array_sum( | |
| str_split( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //http://projecteuler.net/index.php?section=problems&id=80(英語) | |
| //http://odz.sakura.ne.jp/projecteuler/index.php?cmd=read&page=Problem%2080 | |
| //Kazua | |
| import java.math.BigDecimal | |
| import java.math.RoundingMode | |
| object problem80 { | |
| def sqrt(n : Int, s : Int, sr : BigDecimal = BigDecimal.valueOf(-1)) : BigDecimal = n match { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| //http://odz.sakura.ne.jp/projecteuler/index.php?cmd=read&page=Problem%2016 | |
| //write kazua | |
| echo array_sum(str_split(bcpow(2, 1000))); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| //write kazua | |
| $n = 20; | |
| echo array_product(range(1, 2 * $n)) / pow(array_product(range(1, $n)), 2); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| //write kazua | |
| echo pow(array_sum(range(1, 100)), 2) | |
| - array_sum(array_map(function ($value) { | |
| return pow($value, 2); | |
| }, | |
| range(1, 100))); |