Euler/euler03.php

21 lines
495 B
PHP
Raw Normal View History

2015-11-15 00:06:08 +01:00
<?php
/*
* Gnieark's anwser to euler problem 3
* https://projecteuler.net/problem=3
*/
2015-11-15 22:53:49 +01:00
require_once("_functions.php");
2015-11-15 00:06:08 +01:00
echo largestPrimeFactorOf(600851475143);
function largestPrimeFactorOf($number){
2015-11-15 22:53:49 +01:00
$right=$number;
$i=1;
$prFact=1;
while(getPrimeNumber($i)<=$right){
if(fmod($right,getPrimeNumber($i))==0){
$prFact=getPrimeNumber($i);
$right=$right/$prFact;
}
$i++;
2015-11-15 00:06:08 +01:00
}
2015-11-15 22:53:49 +01:00
return $prFact;
}