第一篇:10的阶乘
--10的阶乘
declare
n number := 1;
m number := 1;
begin
while n <= 10 loop
m := m * n;
n := n 1;
end loop;
dbms_output.put_line('10!is ' || m);end;
--升级版,求任一数的阶乘
declare
n number;
m number := 1;
j number := 1;
begin
n := #
while j <= n loop
m := m * j;
j := j 1;
end loop;
dbms_output.put_line('The result is ' || m);end;
第二篇:1~20的阶乘
#include
int a;long s=1;
}
{
} int i;long sum=0;for(i=1;i<=20;i )sum=sum fun(i);cout<<“1~20的阶乘之和为:”< import java.util.*; class SumStratum { public static void main(String[] args){ System.out.println(“Please enter a number:”);Scanner sc=new Scanner(System.in);int x=sc.nextInt(); int n=1; long p=1; long sum=0; while(n<=x) { p*=n; System.out.print(n “!” “ ”);n ; sum =p; } System.out.println(“=” sum); } }第三篇:java输入一个数求这个数的阶乘