From 89d2501523560d71384b6b8d489654826ad65f82 Mon Sep 17 00:00:00 2001 From: Tom Barrett Date: Sun, 7 Mar 2021 21:45:31 +0100 Subject: improved 7 --- src/main.zig | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/main.zig b/src/main.zig index 3a194fd..8966363 100644 --- a/src/main.zig +++ b/src/main.zig @@ -136,21 +136,19 @@ fn p6() void { } fn p7() void { - const size: usize = 10_002; - var primes: [size]usize = undefined; - var i: usize = 1; var j: usize = 0; - while (j < size) : (i += 1) { + while (j != 10_002) : (i += 1) { if (is_prime(i)) { - primes[j] = i; j += 1; } } - print("{}\n", .{primes[size - 1]}); + print("{}\n", .{i - 1}); } -fn p8() void {} +fn p8() void { + print("{}\n", .{1}); +} pub fn main() !void { //p1(); @@ -159,6 +157,6 @@ pub fn main() !void { //_ = try p4(); //p5(); //p6(); - //p7(); - p8(); + p7(); + //p8(); } -- cgit v1.2.3