summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom Barrett <tom@tombarrett.xyz>2021-03-07 21:45:31 +0100
committerTom Barrett <tom@tombarrett.xyz>2021-03-07 21:45:31 +0100
commit89d2501523560d71384b6b8d489654826ad65f82 (patch)
treee74de51c2b6d50dbe8fec3046eedf3eea6957ef7 /src
parent44311378add75eebf87d41607fa8fb12cf5fa2e5 (diff)
improved 7
Diffstat (limited to 'src')
-rw-r--r--src/main.zig16
1 files changed, 7 insertions, 9 deletions
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();
}