forked from storopoli/Julia-Workshop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
06-for.jl
49 lines (36 loc) · 846 Bytes
/
06-for.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# for-loops
for n in [1, 2, 3, 4, 5]
println(n)
end
for n in 1:2:10
println(n)
end
N = 1_000_000
for n in 0:100_000:N
println(n)
end
# start:step:finish
for i in 1:20
println(i)
end
1:20
rand()
# for-loops Exercises
# Write a Julia program to construct this pattern below:
# *
# * *
# * * *
# * * * *
# * * * * *
# * * * *
# * * *
# * *
# *
# Project Euler Problem 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.
# Find the sum of all the multiples of 3 or 5 below 1000.
# Project Euler Problem 2
# Each new term in the Fibonacci sequence is generated by adding the previous two terms.
# By considering the terms in the Fibonacci sequence whose values do not exceed four million,
# find the sum of the even-valued terms.