summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main.zig36
1 files changed, 35 insertions, 1 deletions
diff --git a/src/main.zig b/src/main.zig
index 8261fa0..3a194fd 100644
--- a/src/main.zig
+++ b/src/main.zig
@@ -121,10 +121,44 @@ fn p5() void {
}
}
+fn p6() void {
+ var sum_0: usize = 0;
+ var sum_1: usize = 0;
+
+ var i: usize = 1;
+ while (i <= 100) : (i += 1) {
+ sum_0 += i * i;
+ sum_1 += i;
+ }
+ sum_1 *= sum_1;
+
+ print("{}\n", .{sum_1 - sum_0});
+}
+
+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) {
+ if (is_prime(i)) {
+ primes[j] = i;
+ j += 1;
+ }
+ }
+ print("{}\n", .{primes[size - 1]});
+}
+
+fn p8() void {}
+
pub fn main() !void {
//p1();
//p2();
//p3();
//_ = try p4();
- p5();
+ //p5();
+ //p6();
+ //p7();
+ p8();
}