# I am new to Julia, could someone help me to check the code?

**URL:** https://discourse.julialang.org/t/i-am-new-to-julia-could-someone-help-me-to-check-the-code/45528
**Category:** New to Julia
**Tags:** question, homework
**Created:** [August 25, 2020, 6:50pm UTC](https://discourse.julialang.org/t/i-am-new-to-julia-could-someone-help-me-to-check-the-code/45528 "2020-08-25T18:50:16Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![MonteKpncto](https://avatars.discourse-cdn.com/v4/letter/m/7ba0ec/32.png) [@MonteKpncto](https://discourse.julialang.org/u/MonteKpncto)
#### Post date: [August 25, 2020, 6:50pm UTC](https://discourse.julialang.org/t/i-am-new-to-julia-could-someone-help-me-to-check-the-code/45528/1 "2020-08-25T18:50:16Z")

</div>

It is a square root language,

```julia

```

---

<div class="post-metadata">

### Author: ![Henrique\_Becker](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/henrique_becker/32/15443_2.png) [@Henrique\_Becker](https://discourse.julialang.org/u/Henrique_Becker)
#### Post date: [August 25, 2020, 6:52pm UTC](https://discourse.julialang.org/t/i-am-new-to-julia-could-someone-help-me-to-check-the-code/45528/2 "2020-08-25T18:52:56Z")

</div>

I recommend you follow the suggestion of [this PSA](https://discourse.julialang.org/t/psa-make-it-easier-to-help-you/14757) and use triple backticks to indent and make your code easier to read.

---

<div class="post-metadata">

### Author: ![pdeffebach](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pdeffebach/32/10320_2.png) [@pdeffebach](https://discourse.julialang.org/u/pdeffebach)
#### Post date: [August 25, 2020, 6:53pm UTC](https://discourse.julialang.org/t/i-am-new-to-julia-could-someone-help-me-to-check-the-code/45528/3 "2020-08-25T18:53:05Z")

</div>

Please quote your code in backticks

````julia
```
like this
```

````

You have `r = 9` and `y = 0`, then you are asserting that `x == y^2`. This is the error you get (which you should also post).

Your code doesn’t work because you have told it to error when there is a false condition! `9 != 0`

---

<div class="post-metadata">

### Author: ![Henrique\_Becker](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/henrique_becker/32/15443_2.png) [@Henrique\_Becker](https://discourse.julialang.org/u/Henrique_Becker)
#### Post date: [August 25, 2020, 6:57pm UTC](https://discourse.julialang.org/t/i-am-new-to-julia-could-someone-help-me-to-check-the-code/45528/4 "2020-08-25T18:57:43Z")

</div>

The error is not `x == y^2` as the code is `x == y^2 + r` (which is correct), the problem is in `0 <= r< 2*y + 1` in the second assert, for `(r, y) = (8, 1)` it evaluates to false as `8 < (2*1 + 1)` is not true.

---

<div class="post-metadata">

### Author: ![jlperla](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jlperla/32/34332_2.png) [@jlperla](https://discourse.julialang.org/u/jlperla)
#### Post date: [August 26, 2020, 3:00am UTC](https://discourse.julialang.org/t/i-am-new-to-julia-could-someone-help-me-to-check-the-code/45528/5 "2020-08-26T03:00:52Z")

</div>

> [@MonteKpncto](#):
>
> `let r=x, y = 0`

I strongly suggest starting with functions (and/or scripts that don’t include `let`, preferably in jupyter). If you are an advanced programmers you will understand `let` quickly, but otherwise you are better off starting without it… it is relatively infrequent in most code.

---

<div class="post-metadata">

### Author: ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)
#### Post date: [August 26, 2020, 7:43am UTC](https://discourse.julialang.org/t/i-am-new-to-julia-could-someone-help-me-to-check-the-code/45528/6 "2020-08-26T07:43:18Z")

</div>

Please don’t post the same question multiple times, this seems to be the same issue as in [this thread](https://discourse.julialang.org/t/i-am-new-to-julia-i-tried-to-write-square-root-program-i-still-can-not-figure-out-whats-wrong/45526/2).

Also is this a homework problem? I ask as someone posted the same question on StackOverflow yesterday and removed it after I asked whether it was a homework problem. It’s fine to ask for help with homework here, but you might want to have a look at our informal [homework policy](https://discourse.julialang.org/t/homework-policy/2342/17).

---

<div class="post-metadata">

### Author: ![mwolff](https://avatars.discourse-cdn.com/v4/letter/m/c2a13f/32.png) [@mwolff](https://discourse.julialang.org/u/mwolff)
#### Post date: [August 26, 2020, 12:30pm UTC](https://discourse.julialang.org/t/i-am-new-to-julia-could-someone-help-me-to-check-the-code/45528/7 "2020-08-26T12:30:00Z")

</div>

Such questions arise frequently, which could easily be answered by reading the documentation. I would not dare to ask something like that
