Calling a function that returns array stops printArray

ha, that’s good
so what you do in that kind of situation is

  • -a- use println(“”); on variables
  • -b- disable lines // or parts of code /* */
    until it works to dig deeper into
    and find the wrong line of code.

your problem is you call

  println("nom "+nom+" denom "+denom);
  int r[]=details(nom,denom);

//shows:
//nom 6 denom 0

now inside

int[] details(int nom, int smallw) {
//..
// you do a for loop
for (int total=smallw; total<=nom; total+=smallw) { }

that can not work good on

total+=0

so a easy fix is

  if (smallw>0) for (int total=smallw; total<=nom; total+=smallw) {

2 Likes