# Adding a variable to itself

**URL:** <https://cl.desmos.com/t/adding-a-variable-to-itself/3297>\
**Category:** Questions\
**Created:** [May 19, 2021, 12:45am UTC](https://cl.desmos.com/t/adding-a-variable-to-itself/3297 "2021-05-19T00:45:32Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bryan\_Gregory](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/bryan_gregory/32/2029_2.png) [@Bryan\_Gregory](https://cl.desmos.com/u/Bryan_Gregory)\
**Post date:** [May 19, 2021, 12:45am UTC](https://cl.desmos.com/t/adding-a-variable-to-itself/3297/1 "2021-05-19T00:45:32Z")

</div>

Hi there,

Quick question (and hopefully a quick answer) - is it possible to add a variable to itself in desmos? In other words, can I define a variable then increment it somehow? For context I’d like to count how many times a student gets the answer correct on a randomly generated practice activity and eventually place a point value based on if they needed a hint or not.

Essentially I want something like this:

a= when “correct answer” a+1 otherwise a

I’ve got a good flow on randomly generating lots of different practice through the CL/calculator in activities, and I think this would be the next level to add some additional tracking engagement. I have fun gifs and word prompts that trigger when something is right, but no way to track how many questions a student actually attempted and got right.

---

<div class="post-metadata">

**Author:** ![Aethir](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/aethir/32/2767_2.png) [@Aethir](https://cl.desmos.com/u/Aethir)\
**Post date:** [May 19, 2021, 2:19am UTC](https://cl.desmos.com/t/adding-a-variable-to-itself/3297/2 "2021-05-19T02:19:46Z")

</div>

I’m not certain there’s a way to do that, but there are other ways to accomplish what you want.

How is a new problem generated after one is completed?

Do you want them to be able to move on to a new problem before correctly solving the current one?

---

<div class="post-metadata">

**Author:** ![cwinske](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/cwinske/32/3106_2.png) [@cwinske](https://cl.desmos.com/u/cwinske)\
**Post date:** [May 19, 2021, 11:09am UTC](https://cl.desmos.com/t/adding-a-variable-to-itself/3297/3 "2021-05-19T11:09:24Z")

</div>

You’ll want to take advantage of using the capture sink when a student submits a problem. If all the problems are on one screen, you can create a variable in the calculator that checks for correctness. Set the variable to 1 on correct, set it to 0 if not correct. The button will capture those values and then you can use the calculator to perform some functions on the numberList history. Here’s an example.

> **[Tracking the Number of Problems • Activity Builder by Desmos](https://teacher.desmos.com/activitybuilder/custom/60a4f03ea5cdef05eae88bc4)**
>
> by Craig Winske

---

<div class="post-metadata">

**Author:** ![Aethir](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/aethir/32/2767_2.png) [@Aethir](https://cl.desmos.com/u/Aethir)\
**Post date:** [May 19, 2021, 12:18pm UTC](https://cl.desmos.com/t/adding-a-variable-to-itself/3297/4 "2021-05-19T12:18:08Z")

</div>

Oooohhhh, Craig’s right. You can effectively increment (if that’s your end goal) by asking for the length of a numberList!

---

<div class="post-metadata">

**Author:** ![Bryan\_Gregory](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/bryan_gregory/32/2029_2.png) [@Bryan\_Gregory](https://cl.desmos.com/u/Bryan_Gregory)\
**Post date:** [May 19, 2021, 1:39pm UTC](https://cl.desmos.com/t/adding-a-variable-to-itself/3297/5 "2021-05-19T13:39:12Z")

</div>

ok wow, very cool! I haven’t used any of this functionality before so I think I need to sit down and code out some examples for myself to internalize it-but yes, this is exactly what I’m looking for.
