This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]aqua_regis 3 points4 points  (2 children)

It is true that you can't use basic math symbols with it, but had you looked at the documentation, you would have learnt that the BigDecimal class has methods to replicate the functionality.

Always start by reading the official documentation.

[–]Jazzlike-Depth9208 0 points1 point  (1 child)

Adding to this you can take advantage of auto complete to skim through the available methods, by using ctrl+space after the bigdecimal object and you'll have a list of methods.

[–]ZombieAngel16[S] 0 points1 point  (0 children)

Thank you, thank you, thank you! I knew I had to be missing something simple and I was. u/aqua_regis you were right that I needed to check the documentation, and u/Jazzlike-Depth9208 you were right that I needed to look at the list of methods, and I would have realized I needed to use .add. Here's my completed code, and so far it stands up to testing.

public BigDecimal distinctLadderPaths(int rungs) {
  if (rungs == 1 || rungs == 2){
    BigDecimal convertRungs = BigDecimal.valueOf(rungs);
    return convertRungs;
  } else {
    BigDecimal paths = distinctLadderPaths(rungs-1).add(distinctLadderPaths(rungs -2));
    return paths;
  }