-- This is a Lua v5.1.4 script -- Filename a134179.lua.txt -- By Shawn A. Broyles -- Written 11/26/2017 function checkPrime(num) for j = 2, num^(1 / 2) do if (num % j) == 0 then return false end end return true end local infile = "b007468.txt" local outfile = io.open("b134179.txt", "a") local n = 0 for line in io.lines(infile) do local integer = 0 for i in string.gmatch(line, "%d+") do integer = integer + 1 if integer == 2 then if checkPrime(i) then n = n + 1 outfile:write(tostring(n.." "..i), "\n") end end end end print("done") outfile:close()