Skip to content

Instantly share code, notes, and snippets.

@flowl
Created June 25, 2018 14:24
Show Gist options
  • Save flowl/5cbc2bcd515e2b05f5a2e220508526b1 to your computer and use it in GitHub Desktop.
Save flowl/5cbc2bcd515e2b05f5a2e220508526b1 to your computer and use it in GitHub Desktop.
PHP; factorize any integer
<?php
/*
$ php factorize.php 90
Array
(
[2] => 45
[3] => 30
[5] => 18
[6] => 15
[9] => 10
[10] => 9
)
*/
$i++;while($i++<sqrt($a=$argv[1]))!($a%$i)?$b[$i]=$a/$i:'';print_r($b);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment