summaryrefslogtreecommitdiff
path: root/src/main.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.zig')
-rw-r--r--src/main.zig31
1 files changed, 29 insertions, 2 deletions
diff --git a/src/main.zig b/src/main.zig
index f6e3ec2..8261fa0 100644
--- a/src/main.zig
+++ b/src/main.zig
@@ -67,11 +67,14 @@ fn p3() void {
const n: usize = 600851475143;
//const n: usize = 13195;
+ var biggest: usize = 0;
for (primes) |prime| {
if (n % prime == 0) {
- std.debug.warn("{}\n", .{prime});
+ biggest = prime;
}
}
+
+ std.debug.warn("{}\n", .{biggest});
}
fn p4() !void {
@@ -95,9 +98,33 @@ fn p4() !void {
print("{}\n", .{largest});
}
+fn p5() void {
+ var num: usize = 20;
+ var i: usize = 1;
+ var j: usize = 0;
+ var found: bool = false;
+
+ while (i < 1_500_000_000) : (i += 1) {
+ j = num;
+
+ found = false;
+ while (j != 0) : (j -= 1) {
+ if (i % j != 0) {
+ found = true;
+ }
+ }
+
+ if (!found) {
+ print("{}\n", .{i});
+ break;
+ }
+ }
+}
+
pub fn main() !void {
//p1();
//p2();
//p3();
- _ = try p4();
+ //_ = try p4();
+ p5();
}