Sam Trenholme's webpage
Support this website

Lua primes; etc.

 

September 17 2025

A Lua function for finding prime numbers. Also, some links about Charlie Kirk.

Finding primes in Lua

This Lua function finds all primes between 2 and a, and returns the list of primes in an array:

function primes(a)
  local out = {2}
  local inComposite = false
  local c = 1
  for b=3,a,2 do
    isComposite = false
    c = 1
    while out[c]*out[c] <= b
        do
      if(b/out[c] ==
         math.floor(b/out[c]))
      then
        isComposite = true
        break
      end
      c = c + 1
    end
    if not isComposite then
      out[#out + 1] = b
    end
  end
  return out
end

Here’s a function for printing array elements:

function listArray(a)
  local out = ""
  for b=1,#a do
    out = out .. 
          tostring(a[b]) 
          .. " "
  end
  return out
end

Example usage of the above functions:

print(listArray(primes(99)))

Charlie Kirk and Ryan Carson

Ryan Carson is someone who died in 2023. People on the right did some amount of dancing on his grave after he died; how bad that dancing was is something I will leave to the reader. Here is how the right reacted to his death: The Voice of Thy Brother’s Blood - REVEALED: Murdered leftist activist Ryan Carson has history of celebrating death, violence towards conservatives

Charlie Kirk is someone I have already talked about in previous blogs. In terms of the left dancing on his grave, as a point of comparison, here is how someone on the left reacted to Charlie Kirk’s death: The World Is a Better Place Without Charlie Kirk In It

Looking at this short YouTube video of Charlie Kirk, he comes off as someone very compassionate, even to people who have a very different standard of morality than the morality he had—a morality which I myself have (I have never had sex outside of a lifetime monogamous commitment).

Picture attribution

The picture of Charlie Kirk was taken by Gage Skidmore, is available under a CC 4.0 License, and it has been altered for this blog.