1. 写一个脚本,利用循环计算10的阶乘#!/bin/shfactorial=1for a in `seq 1 10`do factorial=`expr $factorial \* $a`doneecho "10! = $factorial"2. 写一个脚本,执行后,打印一行提示“Please i...
分类:
系统相关 时间:
2014-07-22 00:06:35
阅读次数:
502
时间限制:0.25s空间限制:4M题意 你的任务是找到最小自然数 N, 使N!在十进制下包含 Q个零. 众所周知 N! = 1*2*...*N. 例如, 5! = 120, 120 结尾包含1个零.Input 一个数 Q (0using namespace std;int check ...
分类:
其他好文 时间:
2014-07-18 00:10:28
阅读次数:
263
Factovisors
The factorial function, n! is defined thus for n a non-negative integer:
0! = 1
n! = n * (n-1)! (n > 0)
We say that a divides b if there exists an integer k such that
k*a =...
分类:
其他好文 时间:
2014-07-17 19:05:06
阅读次数:
235
define simple method定义简单方法关键字def用于方法定义,在其后是方法名和可选的参数名列表,参数名列表会用一对圆括号括住。构成方法主体的代码放在参数列表之后,end用于结束方法定义。#define a methoddef factorial(n) if n0" ...
分类:
其他好文 时间:
2014-07-06 22:23:36
阅读次数:
241
今天看到一篇关于模版元编程的文章,一开始没看懂是什么意思,于是自己记下来。直接看代码:int factorial(int n) { if (n == 0) return 1; return n * factorial(n - 1);} void foo(){ int x...
分类:
其他好文 时间:
2014-07-06 18:26:22
阅读次数:
130
斐波那契数列的几种不同的算法,递归的不同实现: 1 #include "stdio.h" 2 #include "math.h" 3 4 5 int factorial_tail(int n,int acc1,int acc2) 6 { 7 if (n < 2) 8 re...
分类:
其他好文 时间:
2014-07-06 16:40:31
阅读次数:
204
链接:http://vjudge.net/problem/viewProblem.action?id=19597描述:求n^k的前三位数字和后三位数字思路:题目要解决两个问题。后三位数字可以一边求高次幂一边取模,下面给出求前三位数字的方法。 n^k = (10^lg n)^k = 10^(k*...
分类:
其他好文 时间:
2014-07-01 00:58:29
阅读次数:
202
11. Factorial 这个题同样非常简单,就是求一个数的阶乘的尾部有多少个0. 思路是有2*5才会出0,然后2肯定比5多,所以就是数N!中有多少个因子5. 关于如何数出因子5的个数中http://www.chinaunix.net/old_jh/23/926848.html这篇文章介绍的非常详...
分类:
编程语言 时间:
2014-06-24 14:16:07
阅读次数:
246
n! means n (n
1)
...
3
2
1
For example, 10! = 10 9
...
3
2
1 = 3628800,
and the sum of the digits in the number 10! is 3 + 6 + 2 + 8 + 8 + 0 + 0 = 27.
Find the sum of the digits...
分类:
其他好文 时间:
2014-06-20 09:34:10
阅读次数:
215
function factorial(num){ if(num<=1){ return 1;
}else{ return num * arguments.callee(num-1); //指向一个正在执行函数的指针,可以实现对函数的递归...
分类:
Web程序 时间:
2014-06-11 08:56:56
阅读次数:
244