java - Calculating the connection count of a network -


the question calculate connection count of connected mesh topology network. total number of connections can calculated formula (n x (n-1)) / 2. implement public class connectioncount method recursively , else given us. problem can't compile. trying figure out how call method on later program compile i'm confused. please help, have far:

public class connectioncount { private int n;  public int connectioncalc(int n){  if(n > 0){     return(n-1) + connectioncalc(n-1);     return connectioncalc(n); } else{     return 0; } }     public static int connectioncount(int n) {     return 0; }  public static void main(string [] args) {     (int = 0; < 20; i++)     {         system.out.println("connectioncount(" + + ") returns " + connectioncount(i));      } } } 

just remove second return in code. it's unreachable, compiler undoubtedly telling you.


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -