samples/composition/src-test/org/apidesign/math/test/Factorial.java
author Jaroslav Tulach <jtulach@netbeans.org>
Sun, 06 Oct 2013 22:05:14 +0200
changeset 407 e1439046d96e
permissions -rw-r--r--
Looks like scala change URLs of its releases
     1 package org.apidesign.math.test;
     2 
     3 import org.apidesign.math.Arithmetica;
     4 
     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
    20