Probability for three randomly chosen numbers to be in AP | Java program to find probability that 3 randomly chosen numbers form AP . ; function to calculate probability ; Driver code to run above function
class GFG { static double procal ( int n ) { return ( 3.0 * n ) / ( 4.0 * ( n * n ) - 1 ) ; } public static void main ( String arg [ ] ) { int a [ ] = { 1 , 2 , 3 , 4 , 5 } ; int n = a . length ; System . out . print ( Math . round ( procal ( n ) * 1000000.0 ) / 1000000.0 ) ; } }