Mathworks "Cody"‎ > ‎Problems 20-29‎ > ‎

Problem 26

Given the input n, return true if n is odd or false if n is even.


We've already done this 1,000 times in project Euler. Just do a mod(n,2) check to see if it's even. Check the code!


function[tf] = problem26(n)

    tf = mod(n,2);  % If there is no remained, tf = 0 (even!), if there is a remainder, tf = 1 (true)



Correct, Size 13


I get a size of 13 when the leading solution is size 12. Not sure what I'm doing wrong but it's so close to the leading solution! I'll come back to this later.

Follow me!