# Random Number Generator

**URL:** https://cl.desmos.com/t/random-number-generator/4628
**Category:** Questions
**Created:** [December 23, 2022, 11:55pm UTC](https://cl.desmos.com/t/random-number-generator/4628 "2022-12-23T23:55:46Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Cheryl](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/cheryl/32/4044_2.png) [@Cheryl](https://cl.desmos.com/u/Cheryl)
#### Post date: [December 23, 2022, 11:55pm UTC](https://cl.desmos.com/t/random-number-generator/4628/1 "2022-12-23T23:55:46Z")

</div>

I found this great activity by Jose Ascarrunz which generates random numbers to solve equations. I’m trying to modify it so it only uses positive numbers. It looks like they’re set to be positive, but I get negative numbers when I preview. Here’s a link:

> **[One-Step Equations Practice • Activity Builder by Desmos](https://teacher.desmos.com/activitybuilder/custom/63a63defc5001598a691edca)**
>
> by Cheryl Chaffin

---

<div class="post-metadata">

### Author: ![sergeballif](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/sergeballif/32/231_2.png) [@sergeballif](https://cl.desmos.com/u/sergeballif)
#### Post date: [December 27, 2022, 4:25pm UTC](https://cl.desmos.com/t/random-number-generator/4628/2 "2022-12-27T16:25:25Z")

</div>

The only negative number I see is on the right-hand side of the equation for subtraction. That can be updated by changing `x` to depend on `a` in the component **Problem**. For example, change

```auto
x = numericValue("${r.int(2,10)}*${multiplier}")

```

to

```auto
x = when operation1=2 numericValue("${r.int(a,10)}*${multiplier}")
otherwise numericValue("${r.int(2,10)}*${multiplier}")

```

---

<div class="post-metadata">

### Author: ![Cheryl](https://yyz1.discourse-cdn.com/flex031/user_avatar/cl.desmos.com/cheryl/32/4044_2.png) [@Cheryl](https://cl.desmos.com/u/Cheryl)
#### Post date: [December 28, 2022, 5:24pm UTC](https://cl.desmos.com/t/random-number-generator/4628/3 "2022-12-28T17:24:08Z")

</div>

> [@sergeballif](#):
>
> ```auto
> x = when operation1=2 numericValue("${r.int(a,10)}*${multiplier}")
> otherwise numericValue("${r.int(2,10)}*${multiplier}")
> 
> ```

Thank you, so much!!
