020
This commit is contained in:
parent
60d409a630
commit
371a4589b1
1 changed files with 5 additions and 5 deletions
|
@ -21,8 +21,8 @@ pub fn main() void {
|
|||
//
|
||||
// This function prints, but does not return anything.
|
||||
//
|
||||
fn printPowersOfTwo(numbers: [4]u16) ??? {
|
||||
loop (numbers) |n| {
|
||||
fn printPowersOfTwo(numbers: [4]u16) void {
|
||||
for (numbers) |n| {
|
||||
std.debug.print("{} ", .{twoToThe(n)});
|
||||
}
|
||||
}
|
||||
|
@ -31,13 +31,13 @@ fn printPowersOfTwo(numbers: [4]u16) ??? {
|
|||
// exercise. But don't be fooled! This one does the math without the aid
|
||||
// of the standard library!
|
||||
//
|
||||
fn twoToThe(number: u16) ??? {
|
||||
fn twoToThe(number: u16) u16 {
|
||||
var n: u16 = 0;
|
||||
var total: u16 = 1;
|
||||
|
||||
loop (n < number) : (n += 1) {
|
||||
while (n < number) : (n += 1) {
|
||||
total *= 2;
|
||||
}
|
||||
|
||||
return ???;
|
||||
return total;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue