author | Jaroslav Tulach <jtulach@netbeans.org> |
Sun, 06 Oct 2013 22:05:14 +0200 | |
changeset 407 | e1439046d96e |
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