Here you can find the source of factorialAsDoubleIncludeDivisor(int n, double divisor)
Parameter | Description |
---|---|
n | a parameter |
divisor | a parameter |
public static double factorialAsDoubleIncludeDivisor(int n, double divisor)
//package com.java2s; /*//from www .j a va 2 s . c o m * Java Information Dynamics Toolkit (JIDT) * Copyright (C) 2012, Joseph T. Lizier * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ public class Main { /** * Computes n! as a double (to provide extended range over a long). * * We include the divisor here since n! hits with n at about 340. * So if there is anything the result would have been divided by, we include it here, * thus extending the range of n the function is suitable for. * * @param n * @param divisor * @return */ public static double factorialAsDoubleIncludeDivisor(int n, double divisor) { double result = 1.0 / divisor; for (int i = 1; i <= n; i++) { result *= (double) i; } return result; } }