Just another update
This commit is contained in:
parent
a25938f123
commit
00a190b0a6
6591 changed files with 94363 additions and 23227 deletions
|
|
@ -1,5 +1,5 @@
|
|||
(defn !! [m n]
|
||||
(apply * (take-while pos? (iterate #(- % m) n))))
|
||||
(->> (iterate #(- % m) n) (take-while pos?) (apply *)))
|
||||
|
||||
(doseq [m (range 1 6)]
|
||||
(prn m (map #(!! m %) (range 1 11))))
|
||||
|
|
|
|||
19
Task/Multifactorial/Java/multifactorial.java
Normal file
19
Task/Multifactorial/Java/multifactorial.java
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
public class MultiFact {
|
||||
private static long multiFact(long n, int deg){
|
||||
long ans = 1;
|
||||
for(long i = n; i > 0; i -= deg){
|
||||
ans *= i;
|
||||
}
|
||||
return ans;
|
||||
}
|
||||
|
||||
public static void main(String[] args){
|
||||
for(int deg = 1; deg <= 5; deg++){
|
||||
System.out.print("degree " + deg + ":");
|
||||
for(long n = 1; n <= 10; n++){
|
||||
System.out.print(" " + multiFact(n, deg));
|
||||
}
|
||||
System.out.println();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +1,4 @@
|
|||
sub mfact($n, :$degree = 1) { [*] $n, *-$degree ...^ * <= 0 }
|
||||
|
||||
for 1 .. 5 -> $degree {
|
||||
say "$degree: ", map &mfact.assuming(:$degree), 1 .. 10;
|
||||
sub mfact($n) { [*] $n, *-$degree ...^ * <= 0 };
|
||||
say "$degree: ", map &mfact, 1..10
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue