-- Notation Test from @jozzyonroblox (enter a number for the first two then the notation you want)
-- Program Input Ex. (10, 26, sigma) or (1, 5, pi) make sure you enter a number for the first two
-- Notations: sigma, pi, quad, exp, log, fac

-- Input 1 = Addition/Multiplied Factor (1, 2, 6)
-- Input 2 = The Number of Loops (100, 250, 30)
-- Input 3 = The Function (sigma, quad, exp)

local SigmaNotation = function(n, a)
    local result = n-1
    for i = 0, a + 1 do
        result = result + i
        print(result, "Term: " .. i)
    end
    print("Final result after " .. a .. " Terms: " .. result)
end

local PiNotation = function(n, a)
    local result = n
    for i = 1, a do
        result = result * (2 * i)
        print(result, "Term: " .. i)
    end
    print("Final result after " .. a .. " Terms: " .. result)
end

local QuadraticFunction = function(n, a)
    local result = n
    for i = 1, a do
        result = n * (i ^ 2)
        print(result, "Term: " .. i)
    end
    print("Final result after " .. a .. " Terms: " .. result)
end

local ExponentialFunction = function(n, a)
    local result = n
    for i = 1, a do
        print(result, "Term: " .. i)
        if i >= a then
            break
        end
        result = result * n
    end
    print("Final result after " .. a .. " Terms: " .. result)
end

local LogarithmicFunction = function(n, a)
    local result = n
    for i = 1, a do
        result = math.log10(n * i)
        print(result, "Term: " .. i)
    end
    print("Final result after " .. a .. " Terms: " .. result)
end

local FactorialFunction = function(n, a)
    if n < 1 then return end
    local result = n
    for i = 1, a do
        result = result * i
        print(result, "Term: " .. i)
    end
    print("Final result after " .. a .. " Terms: " .. result)
    return result
end






























































































































































































































































local input = io.read()

if not input then
    return print("You did not enter a notation. Use the (1, 20, pi) (NO PARENTHESIS) as an example.")
end

local num1, num2, notation = input:match("([%-]?[%d%.]+),%s*([%-]?[%d%.]+),%s*(%a+)")
num1 = tonumber(num1)
num2 = tonumber(num2)

if notation == "sigma" then
    SigmaNotation(num1, num2)
elseif notation == "pi" then
    PiNotation(num1, num2)
elseif notation == "quad" then
    QuadraticFunction(num1, num2)
elseif notation == "exp" then
    ExponentialFunction(num1, num2)
elseif notation == "log" then
    LogarithmicFunction(num1, num2)
elseif notation == "fac" then
    FactorialFunction(num1, num2)
else
    print("No valid notation entered. Use the 'sigma', 'pi', 'quad', 'exp', 'log', or 'fac' functions for the output to work.")
end

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: