factor
- factor(number)
- number positive integer, real
COPY/// factor(number)
//
// Returns a ds_list containing the prime factors of a given integer.
//
// number positive integer, real
//
/// gmlscripts.pro/license
{
var num,dsid,check;
num = argument0;
dsid = ds_list_create();
check = 2;
while (sqr(check) <= num) {
if (num mod check == 0) {
ds_list_add(dsid,check);
num = num div check;
}else{
check += 1;
}
}
if (num != 1) {
ds_list_add(dsid,num);
}
return dsid;
}
Contributors: xot
GitHub: View · Commits · Blame · Raw