[ALGO-2] 最大最小公倍数

算法训练 最大最小公倍数  
时间限制:1.0s   内存限制:256.0MB
      
问题描述

已知一个正整数N,问从1~N中任选出三个数,他们的最小公倍数最大可以为多少。

输入格式

输入一个正整数N。

输出格式
输出一个整数,表示你找到的最小公倍数。
样例输入
9
样例输出
504
数据规模与约定

1 <= N <= 106


import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		Scanner console = new Scanner(System.in);
		long n = console.nextLong();
		long result;
		if(n <= 2){
			result = n;
		}else if(n % 2 != 0){
			result = n*(n-1)*(n-2);
			}else{
				if(n % 3 == 0){
					result = (n-1)*(n-2)*(n-3);
				}else{
					result = n*(n-1)*(n-3);
				}
			}
		System.out.println(result);
	}
}



猜你喜欢

转载自blog.csdn.net/qq_40395278/article/details/79612699