By studying fossil records, scientists recognized that many animal phyla started appearing into existence about 541 million years ago (Cambrian period). During this time, life on Earth probably went through rapid evolution as all the major animal groups suddenly appeared. Scientists called this period as “Cambrian explosion”.

Why did many…

Today, I will describe a new sorting algorithm: Merge Sort, a divide-and-conquer algorithm invented by John von Neumann in 1945. The general idea of merge sort is: when you solve a problem, if you can split the problem into two halves, solve each of them, one at a time (which…

Visual representation of Shell Sort

Hi guys! In this blog, I’m going to explain to you about the “Power” of Shell Sort. Enjoy!

As you guys know, Donald L. Shell “gave birth” to the Shell Sort algorithm. He made substantial improvements to the insertion sort algorithm. This modified version is now called Shell sort. The…

Computer Science

Someone once asked me, “What is computer science and why is it so fascinating to study?” To answer that question, Computer Science is the study of algorithmic processes and computational machines. …

Last time, I showed you how to iterate through one list. But sometimes, you will have to iterate through more than one list. For example, you have two lists. One has even numbers, and the other one has odd numbers. You want to find the sum of the first two…

In my last blog, I showed you the slower version of how to tell if a number is prime or not. Last time, I promised you that I’d show you the faster version in my next blog.

So, here it is:

x = 17
i = 0
length = len(the_primes)
the_primes = [2,3,5,7,11,13]
is_prime = True
while i < length:
if x % the_primes[i] == 0:
is_prime = False
i = i + 1
if is_prime == True:
print((f'{x} is a prime number!'))
print((f'{x} is not a prime number'))

Input: x = 17

Output: 17 is a prime number!

I found out that you really don’t have to divide it by all the numbers before the number. You only have to divide it by the prime numbers before it.

A prime number is a number greater than 1 that is not a product of two smaller natural numbers. For example, 3 is prime because the only ways of writing it as a product, 1 × 3 or 3 × 1, involve 3 itself. But 6 isn’t a prime number…


Hi! I'm an elementary school student.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store