Field biologists run a field experiment over days to assess the population of an invasor insect species.
An insect trap is set on the first day, and a new trap is added every day, so on the th day, traps are deployed. Each trap is expected to capture individuals. However, specimens learn to avoid traps, so the effectiveness of the traps decays with time.
For this, the expected number of captured individuals on the -th day is: Thus, the accumulated number of captures after days of field work will be:
Write a function captures(n,K) that receives two
integers: the number of days of the field experiment
()
and the expected captures per trap
()
and returns the expected accumulated number of captures
at the end of the field experiment.
You are not allowed to import any function from math
module.
Using lists is not necessary, and will severely penalize your grade.
Only the function is expected. If you have a main program to test
it, comment it out, or put it inside an
if __name__ == "__main__": conditional.
>>> captures(4,8) 21.333333 >>> captures(8,3) 8.154762 >>> captures(11,5) 13.591409 >>> captures(21,2) 5.436564 >>> captures(8,3) + captures(11,5) 21.746171