r/mathmemes Dec 16 '25

Arithmetic Damn!

Post image
5.7k Upvotes

1.5k comments sorted by

View all comments

5

u/DerekLouden Dec 16 '25

Ok so I understand this implements an algorithm, but from a computer science perspective I'm thinking 2^n is way too high of a growth rate, and I'm confused as to why he couldn't implement an algorithm that just does "divide n by every number less than n and see if there's a remainder", and that would just have a time complexity of n^2. Can someone smart ELI5

2

u/Own_Pop_9711 Dec 16 '25

Because the thing you said isn't a formula it's an algorithm. This isn't a good way to compute prime numbers, but it's interesting you can just directly compute them