1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/samples/composition/src-test/org/apidesign/math/test/Factorial.java Thu Oct 30 21:30:10 2014 +0100
1.3 @@ -0,0 +1,20 @@
1.4 +package org.apidesign.math.test;
1.5 +
1.6 +import org.apidesign.math.Arithmetica;
1.7 +
1.8 +/** Class showing inventive, non-expected use of
1.9 + * Arithmetica methods to do multiplication instead of
1.10 + * addition.
1.11 + */
1.12 +// BEGIN: design.composition.arith.factorial
1.13 +public final class Factorial extends Arithmetica {
1.14 + public static int factorial(int n) {
1.15 + return new Factorial().sumRange(1, n);
1.16 + }
1.17 + @Override
1.18 + public int sumTwo(int one, int second) {
1.19 + return one * second;
1.20 + }
1.21 +}
1.22 +// END: design.composition.arith.factorial
1.23 +