Probability for three randomly chosen numbers to be in AP | CPP program to find probability that 3 randomly chosen numbers form AP . ; function to calculate probability ; Driver code to run above function
#include <bits/stdc++.h> NEW_LINE using namespace std ; double procal ( int n ) { return ( 3.0 * n ) / ( 4.0 * ( n * n ) - 1 ) ; } int main ( ) { int a [ ] = { 1 , 2 , 3 , 4 , 5 } ; int n = sizeof ( a ) / sizeof ( a [ 0 ] ) ; cout << procal ( n ) ; return 0 ; }