Home > Back-end >  The blue cup exercises factorial calculation
The blue cup exercises factorial calculation

Time:10-12

blue cup exercises factorial calculation

Don't know what's the problem, the feeling is not wrong thinking, and solve
 
Package Basic_VIP;

Import the Java. Util. ArrayList;
import java.util.Scanner;
Public class Basic_30 {
Public static void main (String [] args) {
Scanner in=new Scanner(System.in);
Int n=in nextInt ();
ArrayList Alist=new ArrayList<> (a);
Alist. Add (1);
for (int i=1; i<=n; I++) {
Int size=alist. The size ();
For (int j=0; j//every times I first, and then to carry
Int temp=alist. Get (j);
Temp *=I;
Alist. Set (j, temp);
}
For (int m=0; MInt temp1=alist. Get (m);
If (temp1 & gt; 10) {
Alist. Set (m, temp1%10);
Int tempResult=temp1/10;
If (size & lt; {
=m + 1)Alist. Add (tempResult);
} else {
Int temp2=alist. Get (m + 1);
Alist. Set (m + 1, + tempResult temp2);
}
} else {
Alist. Set (m, temp1);
}
}
}
For (int I=alist. The size () - 1; i> - 1; I -) {
System. The out. Print (alist. Get (I));
}
}
}

  • Related