1 solutions

  • 0
    @ 2024-12-10 23:49:12

    C :

    #include <stdio.h>
    #include <stdlib.h>
    int main()
    {
    	
    	int n;	
        long long a[50]={0},i;
        scanf("%d",&n);
        a[1]=1;
        for(i=2;i<=49;i++)
            a[i]=a[i-1]*i;
        printf("%lld",a[n]);
    	return 0;
    }
    
    

    C++ :

    #include<iostream>
    using namespace std;
    long long i,s=1,n;
    int main()
    {
        cin>>n;
        for(i=1;i<=n;i++)
        {
            s*=i;
        }
        cout<<s;
        return 0;
    }
    
    

    Pascal :

    program nnnn(input,output);
    var
        n:int64;
    function get(x:int64):int64;
    begin
        if x=0 then
            exit(1);
        exit(get(x-1)*x);
    end;
    begin
        readln(n);
        if n<0 then
        	writeln(1)
        else
        	writeln(get(n));
    end.
    

    Python :

    # coding=utf-8
    n=int(input())
    s=1
    for i in range(1,n+1):
        s=s*i
    print(s)
            
    
    • 1

    Information

    ID
    635
    Time
    1000ms
    Memory
    128MiB
    Difficulty
    9
    Tags
    # Submissions
    15
    Accepted
    3
    Uploaded By