使用awk求一个数字的阶乘
2013-03-26 15:09
246 查看
BEGIN{print( "enter number:") } #check if is a number $1 ~/^[0-9]+$/ { num=$1 if(num == 0) fact=1 else fact=num for(x=num-1;x>=1;x--){ fact*=x } print fact exit } #not a valid number {printf( "not a number.")}
相关文章推荐
- 一个比较字符串和一个计算N个数字阶乘之和的算法
- 使用while循环,计算一个数字中全部的数字和
- 在进行C#编程时候,有的时候我们需要判断一个字符串是否是数字字符串,我们可以通过以下两种方法来实现。 【方法一】:使用 try{} catch{} 语句。 我们可以在try语句块中试图
- 汇编语言: 从键盘上输入一串字符(用回车键结束,使用 10 号功能调用。)放在 STRING 中,试 编制一个程序测试字符串中是否存在数字。如有,则把 CL 的第 5 位置 1,否则将该位置置 0。
- Golang 中使用 JSON 的一些小技巧 陶文 陶文 3 个月前 有的时候上游传过来的字段是string类型的,但是我们却想用变成数字来使用。 本来用一个json:",string" 就可以支持了
- 在kaldi工具包使用小数字语料库创建一个简单的ASR系统(番外篇)
- 如果系统要使用超大整数(超过long长度范围),请你设计一个数据结构来存储这种超大型数字以及设计一种算法来实现超大整数加法运算
- 写一个方法完成如下功能,判断从文本框textbox1输入的一个字符,如果是数字则求该数字的阶乘,如果是小写字条,则转换为大写,大写字符不变,结果在文本框textbox2中显示
- 使用gen_fsm分配一个5900到65535之间不重复的数字
- 使用 AWK 來做垂直数字相加
- java循环练习:用户输入一个10以内的数字,通过运算求出该数字的阶乘
- 使用Olami SDK实现一个语音输入数字进行24点计算的iOS程序
- 通过调用一个求解阶乘的函数,求解一个三位数,该三位数等于其每位数字的阶乘之和。
- 使用Swing组件显示一个整数的个、十、百位数字 java
- java小练习(输入一个数字,使用if语句判断匹配的数字)
- [cocos2dx笔记013]一个使用CCRenderTexture创建动态纹理显示数字的类
- 有一个字符串,包含数字与字母,编程去除数字,要求:1.在原字符串操作2.使用指针处理
- (使用STL自带的排序函数进行编程7.3.14)UVA 10062 Tell me the frequencies!(求一个字符出现的次数(包括字母和数字)&&按出现的次数降序)
- EularProject 34: 一个数字与他每位数的阶乘和
- 编程实现: 一组数据中只有一个数字出现了一次。其他所有数字都是成对出现的。 请找出这个数字。(使用位运算)