fork download
  1. import java.math.BigInteger;
  2. import java.util.Scanner;
  3.  
  4. public class Main {
  5. public static void main(String[] args) {
  6. Scanner sc = new Scanner(System.in);
  7. int n =sc.nextInt();
  8. int ans=1;
  9. int tmpEven=1;
  10. int tmpOdd=1;
  11. int count=0;
  12. boolean even=false, odd=false;
  13. for (int i = n; i > 0; i--) {
  14. if(count==3){
  15. break;
  16. }
  17. if(BigInteger.valueOf(i).isProbablePrime(1)){
  18. ans=ans*i;
  19. count++;
  20. } else if(i%2 ==0 && !even){
  21. ans=ans*i;
  22. tmpEven=i-2;
  23. even =true;
  24. count++;
  25. } else if(i%2 !=0 && !odd) {
  26. ans=ans*i;
  27. tmpOdd=i-2;
  28. count++;
  29. odd=true;
  30. }
  31. }
  32. if(count != 3){
  33. if(n%2 == 0){
  34. ans=ans*tmpEven;
  35. }else{
  36. ans=ans*tmpOdd;
  37. }
  38. }
  39. System.out.println(ans);
  40. }
  41. }
Runtime error #stdin #stdout 0.05s 246080KB
stdin
Standard input is empty
stdout
Standard output is empty