factorial

    12熱度

    1回答

    #include <stdlib.h> #include <stdio.h> struct node; typedef struct node* PtrToNode; struct node { long long n; PtrToNode next; }; PtrToNode factorial(int n, PtrToNode init); void m

    -2熱度

    1回答

    的階乘它是在一個網站的測試,這裏是代碼 #include <stdio.h> void Print_Factorial (const int N); int main() { int N; scanf("%d",&N); Print_Factorial(N--); return 0; } /* your code will be put i

    -1熱度

    4回答

    我試圖實現一個階乘計算(n!)的解決方案,而不使用遞歸,只使用prolog的retroaction。例如: factorial(0, 1). factorial(1, 1). factorial(2, 2). retroaction(X, Y) :- factorial(K, Y), not(K = X), fail. retroaction(K, Y) :- factorial

    -1熱度

    2回答

    我有一些方法可以找到一個大數的因式。有人可以解釋,它有什麼問題,爲什麼我沒有任何輸出? public static long factorial(long num) { BigInteger numm = BigInteger.valueOf(num); BigInteger fact= BigInteger.valueOf(1); for (; numm.compa

    3熱度

    1回答

    我寫了下面的代碼來查找n !.我通過CLI運行它。 <?php $handle = fopen("php://stdin", "r"); $number = (int) trim(fgets($handle)); $fact = calcFactorial($number); echo $fact . "\n"; function calcFactori

    2熱度

    2回答

    如果我計算factorial(100)然後我得到的[1] 9.332622e+157一個答案,但是當我試圖計算更大的階乘,說factorial(1000)我得到的[1] Inf 的答案是有計算階乘這樣時,我可以使用任意精度的方式計算說factorial(1000000)?

    0熱度

    1回答

    我正在求解的問題的一部分需要查找多個因子的因子。我嘗試過的僞代碼就是這樣。 x = 2 ans = 1 while(x < n): # n is given number if(isPrime(x)): count = 0 temp = x while(temp < n): count += n/temp temp *=

    1熱度

    1回答

    在這裏,有幾個問題是關於如何將值舍入爲已知倍數。例如,有question,但它顯示瞭如何將值四捨五入爲指定倍數(例如,從9到5的倍數將產生10)。我想將一個值舍入到給定數字的最接近的因子。比如讓說,我想一個值向上舍入的48 Factors of 48: 1, 2, 3, 4, 6, 8, 12, 16, 24, 48 最接近的因素。如果我的價值是9我想圍捕到12,我知道做到這一點的唯一方法是用

    -1熱度

    5回答

    /* this program * finds the factorial for any number */ public class forLoop1{ public static void main(int x){ int init; for(init = x; init < 2; init--){ int fina

    1熱度

    1回答

    我正在編寫一個應該輸出用戶輸入的任意數字的階乘的程序。程序正確地給出從0到12的輸出,但是如果我輸入13,輸出是1932053504,但是在我的計算器中,13! = 6227020800. 也在32!和33!,輸出爲負數(32!= -2147483648)。從34開始,輸出爲零(0)。 我該如何解決這個問題?我希望程序提供用戶輸入的任何數字的正確輸出。 import java.util.Scann