Best Answer · By JanBask Data Science Expert
Answered on Jan 7, 2020
Let us find the number of bars by creating a function bar_count
bar_count <- function(pack){
amount_of_ones = pack %% 5
amount_of_fives = (pack - amount_of_ones)/5
return(amount_of_ones+amount_of_fives)
}
Let us check how many bars required for 6kg load
bar_count(6)
Output:
[1] 2 # meaning 2 bars are required for 6 kg load.