bools
This commit is contained in:
@@ -3,18 +3,18 @@ func print_i64[x: I64] : I64
|
||||
|
||||
func is_prime[n: I64]: I64
|
||||
if n <= 1
|
||||
return 0
|
||||
return false
|
||||
if n == 2 || n == 3
|
||||
return 1
|
||||
return true
|
||||
if n % 2 == 0 || n % 3 == 0
|
||||
return 0
|
||||
|
||||
return false
|
||||
|
||||
let i: I64 = 5
|
||||
while i * i <= n
|
||||
if n % i == 0 || n % (i + 2) == 0
|
||||
return 0
|
||||
return false
|
||||
i = i + 6
|
||||
return 1
|
||||
return true
|
||||
|
||||
func main[] : I64
|
||||
let sum: I64 = 0
|
||||
|
||||
@@ -3,7 +3,7 @@ func print_i64[x: I64] : I64
|
||||
|
||||
func num_divisors[n: I64] : I64
|
||||
let end: I64 = isqrt(n)
|
||||
|
||||
|
||||
let result: I64 = 0
|
||||
let i: I64 = 1
|
||||
while i < end + 1
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
func print_i64[x: I64] : I64
|
||||
printf("%ld\n", x)
|
||||
|
||||
func i64_to_string[n: I64] : String
|
||||
func I64.to_string[n: I64] : String
|
||||
let x: I64 = malloc(21)
|
||||
sprintf(x, "%ld", n)
|
||||
return x
|
||||
@@ -14,7 +14,7 @@ func main[] : I64
|
||||
let b: I64 = 500
|
||||
while b < 1000
|
||||
if a * b > out
|
||||
let s: String = i64_to_string(a * b)
|
||||
let s: String = I64.to_string(a * b)
|
||||
let s_rev: String = strrev(s)
|
||||
if strcmp(s, s_rev) == 0
|
||||
out = a * b
|
||||
|
||||
@@ -3,18 +3,18 @@ func print_i64[x: I64] : I64
|
||||
|
||||
func is_prime[n: I64]: I64
|
||||
if n <= 1
|
||||
return 0
|
||||
return false
|
||||
if n == 2 || n == 3
|
||||
return 1
|
||||
return true
|
||||
if n % 2 == 0 || n % 3 == 0
|
||||
return 0
|
||||
|
||||
return false
|
||||
|
||||
let i: I64 = 5
|
||||
while i * i <= n
|
||||
if n % i == 0 || n % (i + 2) == 0
|
||||
return 0
|
||||
return false
|
||||
i = i + 6
|
||||
return 1
|
||||
return true
|
||||
|
||||
func main[] : I64
|
||||
let found: I64 = 0
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
func print_i64[x: I64] : I64
|
||||
printf("%ld\n", x)
|
||||
|
||||
func i64_to_string[n: I64] : String
|
||||
let x: I64 = malloc(21)
|
||||
sprintf(x, "%d", n)
|
||||
func I64.to_string[n: I64] : String
|
||||
let x: String = malloc(21)
|
||||
sprintf(x, "%ld", n)
|
||||
return x
|
||||
|
||||
func main[] : I64
|
||||
let s: String = i64_to_string(58394)
|
||||
let s: String = I64.to_string(58394)
|
||||
print_i64(strlen(s))
|
||||
free(s)
|
||||
Reference in New Issue
Block a user