In this Kata, you will be given an integer array and your task is to return the sum of elements occupying prime-numbered indices. 

~~~if-not:fortran
The first element of the array is at index `0`.
~~~

~~~if:fortran
The first element of an array is at index `1`.
~~~


Good luck! 

If you like this Kata, try:

[Dominant primes](https://www.codewars.com/kata/59ce11ea9f0cbc8a390000ed). It takes this idea a step further.

[Consonant value](https://www.codewars.com/kata/59c633e7dcc4053512000073)

Source: codewars | Difficulty: EASY
Tags: Fundamentals

Data structures

Starter code: def total(arr):
	

Solutions:
def is_prime(n):
	return n >= 2 and all((n % i for i in range(2, 1 + int(n ** 0.5))))

def total(arr):
	return sum((n for (i, n) in enumerate(arr) if is_prime(i)))


def sieve(n):
	(sieve, primes) = ([0] * (n + 1), set())
	for i in range(2, n + 1):
		if not sieve[i]:
			primes.add(i)
			for j in range(i ** 2, n + 1, i):
				sieve[j] = 1
	return primes
PRIMES = sieve(5000)

def total(arr):
	return sum((arr[p] for p in set(range(len(arr))) & PRIMES))


def total(lst):
	return sum((lst[i] for i in primes_gen(len(lst))))

def primes_gen(limit):
	for current in (2, 3, 5, 7):
		if current > limit:
			return
		yield current
	composites = {}
	primes = primes_gen(limit)
	base_prime = next(primes) and next(primes)
	next_square = base_prime * base_prime
	for current in range(9, limit, 2):
		if current in composites:
			sieve = composites.pop(current)
		elif current < next_square:
			yield current
			continue
		else:
			sieve = 2 * base_prime
			base_prime = next(primes)
			next_square = base_prime * base_prime
		current += sieve
		while current in composites:
			current += sieve
		composites[current] = sieve


def total(arr):
	sum = 0
	erastoteme = [True] * len(arr)
	for num in range(2, len(erastoteme)):
		if erastoteme[num]:
			sum += arr[num]
			for nb in range(num * 2, len(erastoteme), num):
				erastoteme[nb] = False
	return sum


def total(arr):
	fin_arr = []
	for i in range(2, len(arr)):
		d = 2
		while i % d != 0:
			d += 1
		if d == i:
			fin_arr.append(arr[i])
	n = sum(fin_arr)
	return n


def is_prime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def total(arr):
	final = 0
	i = 0
	for num in arr:
		if is_prime(i) == True:
			final = final + arr[i]
			i = i + 1
		if i == len(arr):
			return final
		if not is_prime(i) == True:
			i = i + 1
		if i == len(arr):
			return final
	return final


import itertools
import numpy as np
s = np.ones(100000)
s[:2] = s[4::2] = 0
for i in range(3, int(len(s) ** 0.5) + 1, 2):
	if s[i]:
		s[i * i::i] = 0

def total(arr):
	return sum(itertools.compress(arr, s))