Updated License
This commit is contained in:
+31
@@ -0,0 +1,31 @@
|
||||
# The No Vibe Coders Open Source License
|
||||
|
||||
```
|
||||
Copyright (C) 2025 William Welna (wwelna@occultusterra.com)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following condition.
|
||||
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
In addition, the following restrictions apply:
|
||||
|
||||
* The software, either in source or compiled binary form, with or without any
|
||||
modification, may not be used with or incorporated into any other software
|
||||
that used an Artificial Intelligence (AI) model and/or Large Language Model
|
||||
(LLM) to generate any portion of that other software's source code, binaries,
|
||||
or artwork.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
```
|
||||
@@ -6,8 +6,9 @@ Sieve of Eratosthenes to find all 32-bit prime numbers in Zig. Uses the same alg
|
||||
wwelna@COINTEL-WORKSTATION:~/GitHub/SieveEratosthenes-zig$ zig build -Doptimize=ReleaseFast run
|
||||
```
|
||||
|
||||
## License
|
||||
## The No Vibe Coders Open Source License
|
||||
|
||||
```
|
||||
Copyright (C) 2025 William Welna (wwelna@occultusterra.com)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
@@ -15,10 +16,18 @@ of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
furnished to do so, subject to the following condition.
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
In addition, the following restrictions apply:
|
||||
|
||||
* The software, either in source or compiled binary form, with or without any
|
||||
modification, may not be used with or incorporated into any other software
|
||||
that used an Artificial Intelligence (AI) model and/or Large Language Model
|
||||
(LLM) to generate any portion of that other software's source code, binaries,
|
||||
or artwork.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
@@ -27,3 +36,4 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
```
|
||||
+27
-18
@@ -5,10 +5,18 @@
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
// furnished to do so, subject to the following condition.
|
||||
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
// * The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
|
||||
// In addition, the following restrictions apply:
|
||||
|
||||
// * The software, either in source or compiled binary form, with or without any
|
||||
// modification, may not be used with or incorporated into any other software
|
||||
// that used an Artificial Intelligence (AI) model and/or Large Language Model
|
||||
// (LLM) to generate any portion of that other software's source code, binaries,
|
||||
// or artwork.
|
||||
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
@@ -21,27 +29,27 @@
|
||||
const std = @import("std");
|
||||
|
||||
const max_num_32 = std.math.maxInt(u32);
|
||||
const max_u64_need_32 = ((max_num_32 / 8)/8);
|
||||
const max_u64_need_32 = ((max_num_32 / 8) / 8);
|
||||
|
||||
inline fn setBit(sieve:[]u64, i:usize) void {
|
||||
sieve[i/64] |= @as(u64, 1) << @intCast(i % 64);
|
||||
inline fn setBit(sieve: []u64, i: usize) void {
|
||||
sieve[i / 64] |= @as(u64, 1) << @intCast(i % 64);
|
||||
}
|
||||
|
||||
inline fn getBit(sieve:[]u64, i:usize) bool {
|
||||
if(sieve[i/64] & @as(u64, 1) << @intCast(i % 64)>0) {
|
||||
inline fn getBit(sieve: []u64, i: usize) bool {
|
||||
if (sieve[i / 64] & @as(u64, 1) << @intCast(i % 64) > 0) {
|
||||
return true;
|
||||
} else return false;
|
||||
}
|
||||
|
||||
inline fn writeToFile(sieve:[]u64) !void {
|
||||
var buffer:[8096]u8 = undefined;
|
||||
const file = try std.fs.cwd().createFile("SieveEratosthenes-Zig.bin", .{.truncate=true});
|
||||
inline fn writeToFile(sieve: []u64) !void {
|
||||
var buffer: [8096]u8 = undefined;
|
||||
const file = try std.fs.cwd().createFile("SieveEratosthenes-Zig.bin", .{ .truncate = true });
|
||||
defer file.close();
|
||||
var writer = file.writer(&buffer);
|
||||
|
||||
var x:usize = 2;
|
||||
var x: usize = 2;
|
||||
while (x <= max_num_32) : (x += 1) {
|
||||
if(!getBit(sieve, x)) {
|
||||
if (!getBit(sieve, x)) {
|
||||
const bytes = std.mem.toBytes(std.mem.nativeToBig(u32, @as(u32, @truncate(x))));
|
||||
_ = try writer.interface.write(&bytes);
|
||||
}
|
||||
@@ -57,15 +65,16 @@ pub fn main() !void {
|
||||
var stdout_writer = std.fs.File.stdout().writer(&stdout_buffer);
|
||||
const stdout = &stdout_writer.interface;
|
||||
|
||||
var sieve_32:[]u64 = undefined;
|
||||
sieve_32 = try allocator.alloc(u64, max_u64_need_32); @memset(sieve_32, 0);
|
||||
var sieve_32: []u64 = undefined;
|
||||
sieve_32 = try allocator.alloc(u64, max_u64_need_32);
|
||||
@memset(sieve_32, 0);
|
||||
|
||||
try stdout.print("Starting...\n", .{});
|
||||
try stdout.flush();
|
||||
var x:usize = 2;
|
||||
var x: usize = 2;
|
||||
while (x * x <= max_num_32) : (x += 1) {
|
||||
if (!getBit(sieve_32, x)) {
|
||||
var y:usize = x * x;
|
||||
var y: usize = x * x;
|
||||
while (y <= max_num_32) : (y += x) {
|
||||
setBit(sieve_32, y);
|
||||
}
|
||||
@@ -79,4 +88,4 @@ pub fn main() !void {
|
||||
|
||||
try stdout.flush();
|
||||
arena.deinit();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user