Sorry, Sorry!!
I had to leave on a trip right after I posted this, so I didn't really explain it.
basically, I get a number, (1260) and I try to find all the factors.
lines 11-21 try to do this.
first, in line 11, we start the loop to go through every number(counter) under x.
in line 13, we see if counter is a factor of x, (if the remainder is 0, then it should be a factor)
if it is, we add it to the factarray array.
the var dumps are there for me to kind of see where the error is.
-
1.
-
<?php
-
2.
-
-
3.
-
-
4.
-
function findfacts($x) {
-
5.
-
-
6.
-
-
7.
-
$counter = 1;
-
8.
-
$factarray;
-
9.
-
$factarraycounter = 0;
-
10.
-
-
11.
-
while ($counter < $x) {
-
12.
-
-
13.
-
if ($x % $counter = 0){
-
14.
-
-
15.
-
$factarray[$factarraycounter] = $counter;
-
16.
-
$factarraycounter++;
-
17.
-
}
-
18.
-
-
19.
-
-
20.
-
$counter++;
-
21.
-
}
-
22.
-
-
23.
-
var_dump($factarray);
-
24.
-
return $factarray;
-
25.
-
}
-
26.
-
-
27.
-
-
28.
-
-
29.
-
-
30.
-
-
31.
-
-
32.
-
-
33.
-
-
34.
-
-
35.
-
-
36.
-
$input = 1260;
-
37.
-
-
38.
-
-
39.
-
-
40.
-
$factarray = findfacts($input);
-
41.
-
-
42.
-
-
43.
-
-
44.
-
var_dump($factarray);
-
45.
-
?>
-
46.
-
-
47.
-
<html><body></body></html>
-
any suggestions?
p.s. I don't really want prime factors, just
all the factors: 1,2,3,6,9,18 for 18. example.
It's for a really basic programming club I belong to. Stress on basic.