mirror of
https://codeberg.org/andyscott/exercism.git
synced 2024-11-14 23:30:48 -05:00
13 lines
228 B
Zig
13 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;
|
||
|
}
|