sorry if this is common knowledge but I am 17, and we've gotten nowhere near this level at school.
Here's the thing:
I'd like to add 1 to a number each time a * 1 + b * 2 = x
. a is a number from 0 to x, and b has to complete going from 0 to the same x before a goes on to the next number in that set of numbers.
In python this would be the following:
x = 200
number = 0
for a in range(0, x+1):
for b in range(0, x+1):
if a * 1 + b * 2 == x:
number += 1
This is a simplified version of the code I wrote that'll find all possible coin combinations for the amount of money in pents you've given as x.
This code works, but I'd like to find a formula for this to implement it in a mathematical way, too.
As far as I understand, you need sigma for this.
This is what I've got already, it's probably extremely incorrect because I am probably the dumbest kid you'll meet.
$$\sum_{ a=0 } ^ { x } { \sum_{b=0}^{x} } $$
And here I need 1 to be added to the solution, if and only if a * 1 + b * 2 is equal to x.
Here I only use two loops, but in my code I go from a to h to find all possible combinations you can make using the following coin options:
1p,2p,5p,10p,20p,50p,100p,200p
In the mathematical case I don't need all the individual combinations only the amount of combinations there are total.
Before anyone asks, yes this is Project Euler #31, but I've already solved it. I'd just like to find a mathematical way to do it and I am not mathematically competent enough to do this without some help.
Also, I don't really know what to tag this as most of these tag names are unknown to me. So feel free to suggest a better tag.