function [i total] = my_program(N) % Function to calculate the sum of the first N numbers divisible by 3 i = 0; n = 0; total = 0; while (n < N) i = i + 1; remainder = mod (i, 3); if (remainder == 0) total = total + i; n = n + 1; end end