samples/composition/src-test/org/apidesign/math/test/Factorial.java
author Jaroslav Tulach <jaroslav.tulach@apidesign.org>
Thu, 30 Oct 2014 21:30:10 +0100
changeset 409 40cabcdcd2be
permissions -rw-r--r--
Updating to NBMs from NetBeans 8.0.1 as some of them are required to run on JDK8
     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