Skip to content
This repository has been archived by the owner on Aug 9, 2024. It is now read-only.

Commit

Permalink
third commit
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilsC8 committed Jun 5, 2024
1 parent 260a682 commit d460995
Showing 1 changed file with 31 additions and 3 deletions.
34 changes: 31 additions & 3 deletions src/main/java/com/utp/clsEstructuraDiscretas/pry4/Formulas.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,47 @@

public class Formulas {

private static BigInteger factorial(int n) {
if (n == 0) {
return BigInteger.ONE;
}
BigInteger result = BigInteger.ONE;
for (int i = 1; i <= n; i++) {
result = result.multiply(BigInteger.valueOf(i));
}
return result;
}
public static Result<BigInteger, Exception> Comb_sin_repeticion(String[] args) {
var this_function = new Object() {}.getClass().getEnclosingMethod().getName();
return Result.error(new UnsupportedOperationException(this_function + " aun no esta listo."));
try {
int n = Integer.parseInt(args[0]);
int r = Integer.parseInt(args[1]);
return Result.ok(factorial(n).divide(factorial(r).multiply(factorial(n - r))));
} catch (Exception e) {
return Result.error(e);
}
}

public static Result<BigInteger, Exception> Comb_con_repeticion(String[] args) {
var this_function = new Object() {}.getClass().getEnclosingMethod().getName();
return Result.error(new UnsupportedOperationException(this_function + " Not supported yet."));
try {
int n = Integer.parseInt(args[0]);
int r = Integer.parseInt(args[1]);
return Result.ok(factorial(n + r - 1).divide(factorial(r).multiply(factorial(n - 1))));
} catch (Exception e) {
return Result.error(e);
}
}

public static Result<BigInteger, Exception> Varianza_sin_repeticion(String[] args) {
var this_function = new Object() {}.getClass().getEnclosingMethod().getName();
return Result.error(new UnsupportedOperationException(this_function + " Not supported yet."));
try {
int n = Integer.parseInt(args[0]);
int r = Integer.parseInt(args[1]);
return Result.ok(factorial(n).divide(factorial(n - r)));
} catch (Exception e) {
return Result.error(e);
}
}

public static Result<BigInteger, Exception> Varianza_con_repeticion(String[] args) {
Expand Down

0 comments on commit d460995

Please sign in to comment.