some small improvements in English
This commit is contained in:
@@ -12,7 +12,7 @@ using InteractiveUtils
|
||||
# First Small Programs
|
||||
|
||||
|
||||
## What Should One Be Able to Do for Programming?
|
||||
## What Skills Are Needed for Programming?
|
||||
|
||||
|
||||
- **Thinking in algorithms:**
|
||||
@@ -30,7 +30,7 @@ using InteractiveUtils
|
||||
|
||||
These cannot all be mastered at once. Be patient with yourself and 'play' with the language.
|
||||
|
||||
The following should serve as a small inspiration.
|
||||
The following examples should serve as inspiration.
|
||||
|
||||
|
||||
## Project Euler
|
||||
@@ -51,7 +51,7 @@ Aufg. 92
|
||||
:::
|
||||
|
||||
::: {.callout-note icon=false .titlenormal}
|
||||
## Project Euler Problem No 1
|
||||
## Project Euler Problem No. 1
|
||||
|
||||
If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.
|
||||
|
||||
@@ -65,7 +65,7 @@ Find the sum of all the multiples of 3 or 5 below 1000.
|
||||
|
||||
2. Implementation:
|
||||
|
||||
How does Julia provide the remainder of integer division? Functions like this are typically called `rem()` (for *remainder*) or `mod()`. [Look it up in the documentation](https://docs.julialang.org/en/v1/base/math/#Base.rem) or try `?rem` and `?mod` in the Julia REPL shows that there are both. The difference lies in the treatment of negative integers. For natural numbers `n,m`, `mod(n,m)` and `rem(n,m)` give the same result, and the latter also has the infix form `n % m`.
|
||||
How does Julia provide the remainder of integer division? Functions like this are typically called `rem()` (for *remainder*) or `mod()`. You can look it up in the documentation or try `?rem` and `?mod` in the Julia REPL. Both functions exist; the difference lies in the treatment of negative integers. For natural numbers `n,m`, `mod(n,m)` and `rem(n,m)` give the same result, and the latter also has the infix form `n % m`.
|
||||
|
||||
How does one test a sequence of values and sum them up? There is a standard pattern: `for` loop and accumulator variable:
|
||||
|
||||
@@ -103,7 +103,7 @@ sum([i for i in 1:999 if i%3==0||i%5==0])
|
||||
|
||||
|
||||
::: {.callout-note icon=false .titlenormal}
|
||||
## Project Euler Problem No 92
|
||||
## Project Euler Problem No. 92
|
||||
A number chain is created by continuously adding the square of the digits in a number to form a new number until it has been seen before.
|
||||
|
||||
For example,
|
||||
@@ -195,7 +195,7 @@ end
|
||||
println("$c numbers below ten million arrive at 89.")
|
||||
```
|
||||
|
||||
Numbers for which the iterative square digit sum calculation ends at 1 are called [happy numbers](https://en.wikipedia.org/wiki/Happy_number), and we have just calculated the number of sad numbers less than 10,000,000.
|
||||
Numbers for which the iterative square digit sum calculation ends at 1 are called [happy numbers](https://en.wikipedia.org/wiki/Happy_number); all other numbers eventually reach the 89-cycle.
|
||||
|
||||
Here is the complete program again:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user