[Odin] Iterate all values and store to RGB pixels[Odin] Iterate all values and store to RGB pixels
📉
Collatz Conjecture
Week 16, 2026
package main
import "core:image"
import "core:image/bmp"
WIDTH, HEIGHT :: 1000, 1000
RESULT_BMP :: "result.bmp"
main :: proc () {
pixels := make([][3] u8, WIDTH*HEIGHT)
defer delete(pixels)
for i in 0.. (evens, odds, quotient: int) {
n := start_n
max_n := n
for {
if n % 2 == 0 {
evens += 1
n /= 2
} else {
odds += 1
n = 3*n + 1
max_n = max(max_n, n)
}
if n == 1 {
odds += 1
break
}
}
quotient = max_n / start_n
return
}
write_bmp :: proc (pixels: [][3] u8, width, height: int, filename: string) {
img, ok := image.pixels_to_image(pixels, width, height)
assert(ok)
err := bmp.save(filename, &img)
assert(err == nil)
}