local p = {} local convert = require('মডিউল:সংখ্যা রূপান্তরকারী').convert  function p.collatz(frame)     local n = tonumber(frame.args[1])  -- Input number     if not n or n < 1 then         return "দয়া করে একটি ধনাত্মক পূর্ণ সংখ্যা প্রদান করুন।"     end      local bold = frame.args['bold']  -- Bold parameter (even/odd)     local max = tonumber(frame.args['max'])  -- Maximum steps     local display_steps = frame.args['steps'] == "yes"  -- Display total steps     local hide_sequence = frame.args['hide'] == "yes"  -- Hide the sequence     local counter = frame.args['counter']  -- Counter parameter (even, odd, or both)      -- Check if both 'hide' and 'max' are set (conflict)     if hide_sequence and max then         return "ত্রুটি: ক্রমটি লুকানো হয়েছে। দয়া করে 'max' প্যারামিটারটি অপসারণ করুন।"     end      local sequence, count = {}, 0  -- Initialize sequence and step counter     local even_count, odd_count = 0, 0  -- Counters for even and odd numbers      -- Helper to conditionally bold numbers     local function maybe_bold(num)         local result = tostring(num)         if (num % 2 == 0 and bold == "even") or (num % 2 ~= 0 and bold == "odd") then             return "" .. convert('bn', tostring(result)) .. ""  -- Bold even or odd numbers         end         return convert('bn', tostring(result))  -- Return unbolded if condition not met     end      -- Function to handle the Collatz logic and format sequence     local function collatz_step(num)         if num % 2 == 0 then             even_count = even_count + 1  -- Increment even count         else             odd_count = odd_count + 1  -- Increment odd count         end         table.insert(sequence, maybe_bold(num))         count = count + 1  -- Increment step count         return num % 2 == 0 and num / 2 or 3 * num + 1  -- Next Collatz step     end      -- Main Collatz loop     while n > 1 do         if max and count >= max then  -- Stop if max steps reached             table.insert(sequence, "..." .. tostring(math.floor(math.log(n, 2)) + 1) .. " আরো")  -- Estimate remaining steps             break         end         n = collatz_step(n)  -- Perform Collatz step     end     collatz_step(n)  -- Final step to 1      -- Handle 'hide' option     if hide_sequence then         local result = ""  -- Initialize result for hidden sequence          -- Add counter information         if counter == "even" then             result = "(জোড় সংখ্যা: " .. even_count .. ")"         elseif counter == "odd" then             result = "(বিজোড় সংখ্যা: " .. odd_count .. ")"         elseif counter == "both" then             result = "(জোড় সংখ্যা: " .. even_count .. ", বিজোড় সংখ্যা: " .. odd_count .. ")"         end          -- Add step count if requested         if display_steps then             result = result .. (result ~= "" and " " or "") .. "(মোট ধাপ: " .. (count - 1) .. ")"  -- Add step info         end          -- If neither counters nor steps were added, return default hidden message         if result == "" then             return "(ক্রম লুকানো)"         else             return result         end     end      -- Build the result: sequence and optionally steps     local result = table.concat(sequence, ", ")     if display_steps then         result = result .. " (মোট ধাপ: " .. (count - 1) .. ")"  -- Steps should now decrement by 1     end      -- Add even and odd counter information if the 'counter' parameter is set     if counter == "even" then         result = result .. even_count .. "even"     elseif counter == "odd" then         result = result .. odd_count .. "odd"     elseif counter == "both" then         result = result .. even_count .. "even" .. "and" .. odd_count .. "odd"     end      return result end  return p