September 2017 Update
This commit is contained in:
parent
bba7bfd280
commit
ba8067c3b7
14570 changed files with 153136 additions and 63871 deletions
|
|
@ -0,0 +1,8 @@
|
|||
fcn factorize(x,y,z,etc){
|
||||
xyzs:=vm.arglist;
|
||||
fs:=xyzs.apply(factors.strand) // queue up factorizing for x,y,...
|
||||
.apply("noop") // wait for all threads to finish factoring
|
||||
.apply(fcn{ (0).min(vm.arglist) }); // find minimum factor for x,y...
|
||||
[0..].zip(fs).filter(fcn([(n,x)],M){ x==M }.fp1((0).max(fs))) // find max of mins
|
||||
.apply('wrap([(n,_)]){ xyzs[n] }) // and pluck src from arglist
|
||||
}
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
factorize(12757923,12878611,12757923,15808973,15780709,197622519).println();
|
||||
// do a bunch so I can watch the system monitor
|
||||
factorize( (0).pump(5000,List,fcn{(1000).random() }).xplode() ).println();
|
||||
13
Task/Parallel-calculations/Zkl/parallel-calculations-3.zkl
Normal file
13
Task/Parallel-calculations/Zkl/parallel-calculations-3.zkl
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
fcn factors(n){ // Return a list of factors of n
|
||||
acc:=fcn(n,k,acc,maxD){ // k is 2,3,5,7,9,... not optimum
|
||||
if(n==1 or k>maxD) acc.close();
|
||||
else{
|
||||
q,r:=n.divr(k); // divr-->(quotient,remainder)
|
||||
if(r==0) return(self.fcn(q,k,acc.write(k),q.toFloat().sqrt()));
|
||||
return(self.fcn(n,k+1+k.isOdd,acc,maxD))
|
||||
}
|
||||
}(n,2,Sink(List),n.toFloat().sqrt());
|
||||
m:=acc.reduce('*,1); // mulitply factors
|
||||
if(n!=m) acc.append(n/m); // opps, missed last factor
|
||||
else acc;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue