I didn’t understand the instruction of this challenge on codewars
platform. I didn’t understand how to calculate the system 2
.
So I need explanation about how to calculate system 2
If John goes to the cinema 3 times or 5 times?
I only see System A and System B there. I will presume that you mean system B instead.
Here is the example they give for calculating things.
System A : 15 * 3 = 45
System B : 500 + 15 * 0.90 + (15 * 0.90) * 0.90 + (15 * 0.90 * 0.90) * 0.90 ( = 536.5849999999999, no rounding for each ticket)
Breaking down System B further, here are the sums:
500
+ 0.9^1 * 15
+ 0.9^2 * 15
+ 0.9^3 * 15
============
536.5849999999999
But when I see on the console the result is 456 not 536.5849999999999
try this:
console.log(
500
+ 0.9^1 * 15
+ 0.9^2 * 15
+ 0.9^3 * 15
)
The ^ symbol doesn’t do the math that you think it does in JavaScript.
You need to use Math.pow(0.9, 2)
to raise 0.9 to the second power.
This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.