作业帮 > 英语 > 作业

英语翻译Use Psendocodeto write an algorithm:Read a number N,then

来源:学生作业帮 编辑:拍题作业网作业帮 分类:英语作业 时间:2024/04/20 14:52:28
英语翻译
Use Psendocodeto write an algorithm:Read a number N,then multiply all the numbers from 1 toN (for example :if N is 5 then add 1*2*3*4*5),Print out the final product.
用psendocode(伪码)写一个算法:
读一个数N
然后把从1到N的数全部乘起来(比如:N=5,那么结果就是1*2*3*4*5)
打出最终的结果.
这个题目的答案是:
Read a N;
int n=N;
int result=1;
while(n>=1)
{
result=n*result;
n=n-1;
}
print out result;