fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. Scanner in = new Scanner(System.in);
  13. int n, m, k = 1;
  14. n = in.nextInt();
  15. m = in.nextInt();
  16. if ( n >= m)
  17. {
  18. System.out.print(0);
  19. }
  20. else
  21. {
  22. for ( int i = 2; i <= n; i++ )
  23. {
  24. k = ( k * i ) % m;
  25. }
  26. System.out.print(k);
  27. }
  28. }
  29. }
Success #stdin #stdout 0.06s 2184192KB
stdin
500 2001
stdout
Standard output is empty