Function to print the nodes with prime degree in the tree whose Prufer sequence is given
static void PrimeDegreeNodes ( int [ ] prufer , int n ) { int nodes = n + 2 ; bool [ ] prime = new bool [ nodes + 1 ] ; for ( int i = 0 ; i < prime . Length ; i ++ ) prime [ i ] = true ; SieveOfEratosthenes ( prime , nodes + 1 ) ;