exercism/zig/eliuds-eggs/eliuds_eggs.zig

12 lines
228 B
Zig

const std = @import("std");
pub fn eggCount(number: usize) usize {
var count: usize = 0;
var temp: usize = number;
while (temp > 0) : (temp /= 2) {
if (temp % 2 != 0) count += 1;
}
return count;
}