diff --git a/examples/twoadicity/src/main.leo b/examples/twoadicity/src/main.leo index 84280c3bab..4f8632b424 100644 --- a/examples/twoadicity/src/main.leo +++ b/examples/twoadicity/src/main.leo @@ -1,11 +1,12 @@ // The 'twoadicity' main function. +@program function main(public n: field) -> u8 { let remaining_n: field = n; let powers_of_two: u8 = 0u8; // Since field ints are 253 bits or fewer, // any number in the field will have at most 252 powers of two in its prime factoring. for i:u8 in 0u8..252u8 { - if (remaining_n / 2field < remaining_n) { + if is_even_and_nonzero(remaining_n) { remaining_n = remaining_n / 2field; powers_of_two = powers_of_two + 1u8; } @@ -21,8 +22,6 @@ function main(public n: field) -> u8 { If we add p to both of these negative numbers, we have n/2 = (n-p)/2 + p = (n+p)/2 is greater than n and still less than p. */ -/* We don't yet have function calls, so this got inlined above. function is_even_and_nonzero (n: field) -> bool { return n / 2field < n; } -*/