Updated problems to be more in line with conventions

This commit is contained in:
2020-06-19 19:58:36 -04:00
parent 1bfd097fa3
commit 7d107c1071
31 changed files with 174 additions and 182 deletions

View File

@@ -1,11 +1,11 @@
--ProjectEuler/lua/Problem1.lua
--Matthew Ellison
-- Created: 02-01-19
--Modified: 03-28-19
--Modified: 06-19-20
--The sum of the even Fibonacci numbers less than 4,000,000
--All of my requires, unless otherwise listed, can be found at https://bitbucket.org/Mattrixwv/luaClasses
--[[
Copyright (C) 2019 Matthew Ellison
Copyright (C) 2020 Matthew Ellison
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
@@ -25,16 +25,16 @@
require "Stopwatch"
timer = Stopwatch:create();
local timer = Stopwatch:create();
timer:start();
--Setup the variables
TOP_NUM = 4000000; --The highest looked for Fibonacci numbers
fibSum = 0; --Holds the sum of the Fibonacci numbers
fibNums = {1, 1, 2}; --An array to keep track of the Fibonacci numbers
local fibSum = 0; --Holds the sum of the Fibonacci numbers
local fibNums = {1, 1, 2}; --An array to keep track of the Fibonacci numbers
--Loop to generate the Fibonacci numbers
cnt = 2; --A counter to hold the location in the array of the currently working Fibonacci number
local cnt = 2; --A counter to hold the location in the array of the currently working Fibonacci number
fibNums[(cnt % 3) + 1] = fibNums[((cnt - 1) % 3) + 1] + fibNums[((cnt - 2) % 3) + 1];
while(fibNums[(cnt % 3) + 1] < TOP_NUM) do
--If the number is even add it to the sum, otherwise ignore it