寻找阶乘的平方根

编程入门 行业动态 更新时间:2024-10-18 01:30:31
本文介绍了寻找阶乘的平方根的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

假设我已经找到2000的阶乘.那么,如果我必须找出大阶乘的平方根,那么该怎么办?我可以认为它可能是牛顿拉夫森方法.

suppose i have found out the factorial of 2000. then if i have to find out the square root of the large factorial..then what to do?? can some one plzz frwd the algo for it..i think it might be newton raphson method.

推荐答案

如果您知道方法名,那么为什么不尝试此 [ ^ ]开头?

如果您知道您将采用阶乘函数结果的平方根,只需实现一个直接计算阶乘的平方根的函数即可: 因为factorial(n)是2到n的整数的乘积 阶乘(n)的平方根是从2到n的每个整数的平方根的乘积 或更有效: 返回Math.Pow(factorial(n), 0.5)(假设factorial(n)是类型double) 如果您的factorial(n)返回BigInteger,请使用Math.Exp(Math.BigInteger(factorial(n))/2.0) 我忘记了您指出您使用的语言是C: 概念相同,但功能名称不同. If you know that you will be taking the square root of the result of the factorial function, just implement a function that directly computes the square root of factorial: since factorial(n) is the product of the integers from 2 to n square root of factorial(n) is the product of the square root of each of those integers from 2 to n or, more efficient: return Math.Pow(factorial(n), 0.5) (assuming factorial(n) is type double) if your factorial(n) is returning BigInteger, then use Math.Exp(Math.BigInteger(factorial(n))/2.0) I forgot that you indicated that the language you''re using is C: The concepts are the same but the function names are different.

#include <stdio.h> #include <math.h> int main() { long double c, n, fact = 1; printf("Enter a number to calculate it's factorial\n"); scanf("%d", &n); for (c = 1; c <= n; c++) fact = fact * c; long double result=csqrtl(fact); printf("Squareroot of %d = %d\n", n, result); return 0; }

-------------------------------------------------- -------------------------------------------------- 有关平方根的更多详细信息,请参见. www.codecogs/reference/computing/c/math.h/sqrt.php [ ^ ] 我认为这可以解决您的问题. 有关数据类型,请参见下面的我的解决方案

---------------------------------------------------------------------------------------------------- for more details on square root refer to.. www.codecogs/reference/computing/c/math.h/sqrt.php[^] I think this solves your problem. for data type see my solution below

更多推荐

寻找阶乘的平方根

本文发布于:2023-11-28 21:10:55,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1643967.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:阶乘   平方根

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!