有没有办法计算大的因子,即大约n <500 [英] Is there any way to calculate factorials of large no ie of about n&lt;500

查看:63
本文介绍了有没有办法计算大的因子,即大约n <500的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每个数字的出现,即n中的数字0,1,2 ......必须计算

occurence of each digit ie number of 0,1,2... in n! have to be calculated

推荐答案

你有没有为此编写任何代码?或者要求我们编写代码?

您可能面临数据类型大小限制。


问候

Dheeraj Joshi


注意:您可以尝试long long int。
Have you written any code for this? Or asking us to write the code?
You might face datatype size limitation.

Regards
Dheeraj Joshi

Note: You may try long long int.


long long int将在n = 30时进行bork。所以...仅限定制长整数。

除以10的数字,如p * 10,可以用p代替,跟踪''丢失''尾随零。
long long int will bork on n=30. So... custom long integer only.
Numbers that divide by 10, like p*10 may be replaced with p, keeping track of ''lost'' trailing zeroes.


执行此操作的唯一方法是编写自己的长整数,可以处理足够大的数字。如果你正在使用C ++,好消息是这是一个非常常见的任务,因此已经有一些公平的无限精度整数实现。


如果你google一个合适的主题你会在网上找到很多代码snipets以及一些实际的实现,比如SourceForge中提供的BigInt。
The only way to do this is to write your own long integer that can handle large enough numbers. If you are using C++ the good news is that this is quite a common task so there are already a fair few unlimited precision integer implementations out there.

If you google an appropriate topic you will find lots of code snipets across the web as well as some actual implementations such as BigInt available in SourceForge.


这篇关于有没有办法计算大的因子,即大约n <500的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆