Octahedral Number | Java program to find nth octahedral number ; Function to find octahedral number ; Formula to calculate nth octahedral number and return it into main function . ; Driver Code ; print result
import java . io . * ; class GFG { static int octahedral_num ( int n ) { return n * ( 2 * n * n + 1 ) / 3 ; } public static void main ( String [ ] args ) { int n = 5 ; System . out . print ( n + " th ▁ Octahedral " + " ▁ number : ▁ " ) ; System . out . println ( octahedral_num ( n ) ) ; } }