Does anyone in the math section understand C++?
You know there's a computer science section, right?
Yes. No one is currently int it.
Whats the question? Id suggest posting it on reddit.
The thing is, before even attempting to successfully write C++ code for this, you first must already know how to solve the math problem on your own.
@Hero Alright, how do I do so?
http://prntscr.com/blh9fc It's supposed to look like this, but when I run it I get a crazy number.
Here's a question for you. Do you think you can come up with the algebraic expression that doubles the salary on a daily basis? How would you construct it and what would it look like. Hint: Start by trying to create the expression for the first couple days.
I'm not sure how to do that.
We know that some company is crazy enough to pay an individual one penny, the first day, two pennies, the second day, and then continues to double his or her salary each day for some unspecified amount of time. So...
What we have to do is "count". When you count in this manner, you start with the following: let n be the number of pennies earned each day so, The first day, the worker earns 1 penny. The second day, the worker earns 2 pennies. The third day, the worker earns 4 pennies ...
The next thing we do is start summing it up because suppose you're the worker. You want to know how much money you've earned in total. So,
1 + 2 + 4 + 8 + ...
Now, here's the thing, you want to come up with a simple expression you can use so that you can create iterations where each iteration represents the nth day. In this case, we can re-write the above expression as 2^0 + 2^1 + 2^2 + 2^3 + ...+2^n
As you can see, the ith term is 2^n
This makes sense, but I'm still unsure how to fix my code.
With this information.
What you want to do is construct your code so that you can input, say, for example, the 365th day that you worked, and then find out how much you earned in one year.
Having the correct expression is half the battle.
From here, you just have to strictly know how to code. I could probably do it in Ruby. I'm not familiar with C++
Alright, let me see.
Join our real-time social learning platform and learn together with your friends!