Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

why is it /by zero???

 
Momo Sawada
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi again... i/ve got a problem with my code... i don't know why it says on the error
Exception in thread "main" java.lang.ArithmeticException: / by zero
at permutation.main(permutation.java:47)

codecodecode:

can anyone help me please??
thank you!!!
 
Rob Spoor
Sheriff
Pie
Posts: 20511
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Obviously down is 0, because that's the only divisor. What value for "n" and "r" are you using?
 
Kevin P Smith
Ranch Hand
Posts: 362
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What are the values of 'r' & 'n', because this is working for me using



C:\Projects\workspace\TestApp\other>java perm 1 0
down: 1, above: 1, under: 1
The permutation of 1 taken 0 is 1

C:\Projects\workspace\TestApp\other>java perm 0 1
own: 1, above: 1, under: -1
he permutation of 0 taken 1 is 1

C:\Projects\workspace\TestApp\other>java perm 0 0
down: 1, above: 1, under: 0
The permutation of 0 taken 0 is 1

C:\Projects\workspace\TestApp\other>java perm 1 1
C:\Kukri\workspace\TestApp\other>ja
down: 1, above: 1, under: 0
The permutation of 1 taken 1 is 1

C:\Projects\workspace\TestApp\other>java perm -1 0
down: 1, above: 1, under: -1
The permutation of -1 taken 0 is 1

C:\Projects\workspace\TestApp\other>java perm 0 -1
down: 1, above: 1, under: 1
The permutation of 0 taken -1 is 1
 
Momo Sawada
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rob Spoor wrote:Obviously down is 0, because that's the only divisor. What value for "n" and "r" are you using?

umm... the user inputs 'n' and 'r'... then the program parses its.. and the integer 'under' is 'n-r'...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic