Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 1

#include <iostream>

using namespace std;


int main()
{
int i,n,c,k,t,a[200],total,temp,x,image;
cin>>t;
while(t--)
{a[0]=1;
cin>>n;
image=n;
for(c=0;image>0;c++)
{
a[c]=image%10;
image=image/10;
}
temp=0;
x=0;
while(n--)
{ for(i=0;i<c;i++)
{
x=a[i]*(n-1)+temp;
a[i]=x%10;
temp=x/10;
}
if(temp!=0)
{
a[c]=temp%10;
temp=temp/10;
c=c+1;
}
}
for(k=c-1;k>=0;k--)
cout<<a[k];
}
return 0;
}

You might also like