304 North Cardinal St.
Dorchester Center, MA 02124

# C – Chef and Maths CodeChef Solution

## C – Chef and Maths CodeChef Solution in C++14

``````// i am seven star coder
// i am working in google

#include <bits/stdc++.h>
using namespace std;

#define int long long
#define ll long long
#define ld long double
#define f first
#define s second
int mod=1e9+7;

void solve(){

int arr[1000001];int first=1;

arr[0]=1;
for(int i=1; i<1000001; i++){
first=(i*first)%mod;
arr[i]=(first*arr[i-1])%mod;
}
int n;
cin>>n;
while(n--){
int s;
cin>>s;
cout<<arr[s]<<'\n';
}
}

int32_t main()
{
ios_base::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
int t=1;
// cin>>t;
while(t--){
solve();
}

return 0;
}``````

## C – Chef and Maths CodeChef Solution in PYTH 3

``````# cook your dish here
t = int(input())
s = []
for i in range(t):
n = int(input())
s.append(n)
n = max(s) + 1
l = [0 for x in range(n)]
p = 1
a = 1
for j in range(1, n):
a = (a * j) % 1000000007
p = p * a % 1000000007
l[j] = p
for k in s:
print(l[k]) ``````

## C – Chef and Maths CodeChef Solution in C

``````#include <stdio.h>

// loops
#define rep(i, n) for(int i=0; i<n; i++)
#define repA(i, a, n) for(int i=a; i<n; i++)
#define repD(i, a, n) for(int i=a; i>=n; i--)

// container and contants
#define N 1000001

typedef long long int ll;
typedef unsigned long long ull;

// global constants
int mod=1e9+7;
//modular exponentation
ll modpow(int x, int y)
{
ll res = 1, tmp;
x = x % mod;

while (y > 0)
{
if (y & 1)
{
tmp=res;
tmp*=x;
res = tmp % mod;
}
y = y>>1;
tmp=x;
tmp*=x;
x = tmp % mod;
}
return res;
}
//modular multiplicative inverse
ll modInverse(ll a){
ll z = mod;
ll q = 0, p = 1;
while(a > 1){
ll s = a/mod;
ll t = mod;
mod = a % mod, a = t;
t = q;
q = p - s * q;
p = t;
}
if (p < 0)
p += z;
mod=z;
return p;
}
int main()
{
ll fact[N], ans[N];
ans[0]=fact[0]=1;
repA(i, 1, N){
fact[i]=fact[i-1];
fact[i]*=i;
fact[i]%=mod;
ans[i]=ans[i-1];
ans[i]*=fact[i];
ans[i]%=mod;
}
int t, n;
scanf("%d", &t);
while(t--)
{
scanf("%d", &n);
printf("%lld\n", ans[n]);
}
return 0;
}``````

## C – Chef and Maths CodeChef Solution in JAVA

``````import java.io.*;
import java.util.*;

class mathl {
public static void main(String[] args) throws IOException {
Scanner sc = new Scanner(System.in);
PrintWriter pw = new PrintWriter(System.out);
long mod = 1000000007;
long arr[]=new long[1000001];
long fact[]=new long[1000001];
fact[0]=1;arr[0]=1;
for(int i=1;i<=1000000;i++){
fact[i] = (fact[i-1]*i)%mod;
arr[i]=(arr[i-1]*fact[i])%mod;
}
int t = sc.nextInt();
for(int z=1;z<=t;z++){
int n=sc.nextInt();
pw.println(arr[n]);
}
pw.close();
}
}``````

## C – Chef and Maths CodeChef Solution in PYPY 3

``````from sys import stdin,stdout
from collections import defaultdict
print=stdout.write
T=int(input())
M=1000000007
n=1000005
Array=[1]
f=1
for j in range(1,n+1):
f=f*j
Array.append((f*Array[j-1])%M)
f=f%M
for i in range(T):
n=int(input())
print(str(Array[n])+"\n")``````

## C – Chef and Maths CodeChef Solution in PYTH

``````MX = 10**6
F = [0 for x in range(MX+1)]
MD = 1000000007
F[1] = 1
n = 1
for k in range(2,MX+1):
n = n*k%MD
F[k] = F[k-1]*n%MD
# endfor k
t = int(raw_input())
for i in range(t):
N = int(raw_input())
print F[N]
# endfor i
``````
##### C – Chef and Maths CodeChef Solution Review:

In our experience, we suggest you solve this C – Chef and Maths CodeChef Solution and gain some new skills from Professionals completely free and we assure you will be worth it.

If you are stuck anywhere between any coding problem, just visit Queslers to get the C – Chef and Maths CodeChef Solution.

Find on CodeChef

##### Conclusion:

I hope this C – Chef and Maths CodeChef Solution would be useful for you to learn something new from this problem. If it helped you then don’t forget to bookmark our site for more Coding Solutions.

This Problem is intended for audiences of all experiences who are interested in learning about Programming Language in a business context; there are no prerequisites.

Keep Learning!