Find the permutation of first N natural numbers such that sum of i % Pi is maximum possible | Java implementation of the approach ; Function to find the permutation of the first N natural numbers such that the sum of ( i % Pi ) is maximum possible and return the maximum sum ; Driver code ; Function call
class GFG { static int Max_Sum ( int n ) { return ( n * ( n - 1 ) ) / 2 ; } public static void main ( String [ ] args ) { int n = 8 ; System . out . println ( Max_Sum ( n ) ) ; } }