Program to calculate Variance of first N Natural Numbers | Java program to implement the above approach ; Function to calculate Variance of first N natural numbers ; Driver Code
class GFG { static double find_Variance ( int n ) { long numerator = n * n - 1 ; double ans = ( numerator * 1.0 ) / 12 ; return ans ; } public static void main ( String [ ] args ) { int N = 5 ; System . out . println ( find_Variance ( N ) ) ; } }