Java task

0

I have a problem with the task as follows:

We have n books and put them on the shelves. Each can accommodate k books. Where shelves will be occupied by the book and how books will be used on the last shelf.
How can they solve?

required sample result:
shelf occupied: 10
number of books on the last of occupied shelves: 3

thanks for the reply

0

number of books on last shelf:

if(n%k==0)
    k;
else
    n%k;

number of shelves:

if(n%k==0)
    n/k;
else
    (n/k)+1;

1 użytkowników online, w tym zalogowanych: 0, gości: 1