arrays
This commit is contained in:
10
examples/arrays.zr
Normal file
10
examples/arrays.zr
Normal file
@@ -0,0 +1,10 @@
|
||||
func main[] : I64
|
||||
let xs: Array = Array.new()
|
||||
Array.push(xs, 5242)
|
||||
Array.push(xs, 6533)
|
||||
Array.push(xs, 4574)
|
||||
|
||||
for i in 0:Array.size(xs)
|
||||
xs
|
||||
|> Array.nth(i)
|
||||
|> print_i64()
|
||||
@@ -1,5 +1,5 @@
|
||||
func num_divisors[n: I64] : I64
|
||||
let end: I64 = isqrt(n)
|
||||
let end: I64 = Math.isqrt(n)
|
||||
|
||||
let result: I64 = 0
|
||||
for i in 1:end+1
|
||||
@@ -13,7 +13,7 @@ func num_divisors[n: I64] : I64
|
||||
func main[] : I64
|
||||
let n: I64 = 0
|
||||
let i: I64 = 1
|
||||
while 1
|
||||
while true
|
||||
n = n + i
|
||||
if num_divisors(n) > 500
|
||||
print_i64(n)
|
||||
|
||||
@@ -2,7 +2,7 @@ func main[] : I64
|
||||
let found: I64 = 0
|
||||
|
||||
let i: I64 = 1
|
||||
while 1
|
||||
while true
|
||||
if Math.is_prime(i)
|
||||
found = found + 1
|
||||
if found == 10001
|
||||
|
||||
@@ -7,7 +7,7 @@ func main[] : I64
|
||||
let s: I64 = 1
|
||||
let j: I64 = 0
|
||||
while j < 13
|
||||
s = s * Char.to_i64(nth(n, i + j))
|
||||
s = s * Char.to_i64(String.nth(n, i + j))
|
||||
j = j + 1
|
||||
if s > out
|
||||
out = s
|
||||
|
||||
Reference in New Issue
Block a user