author | Jaroslav Tulach <jaroslav.tulach@apidesign.org> |
Fri, 03 Apr 2020 16:32:36 +0200 | |
changeset 416 | 9ed8788a1a4e |
permissions | -rw-r--r-- |
1 package org.apidesign.math.test;
3 import org.apidesign.math.Arithmetica;
5 /** Class showing inventive, non-expected use of
6 * Arithmetica methods to do multiplication instead of
7 * addition.
8 */
9 // BEGIN: design.composition.arith.factorial
10 public final class Factorial extends Arithmetica {
11 public static int factorial(int n) {
12 return new Factorial().sumRange(1, n);
13 }
14 @Override
15 public int sumTwo(int one, int second) {
16 return one * second;
17 }
18 }
19 // END: design.composition.arith.factorial