##### https://www.student.tugraz.at/elmazovski/dm2/hue01/##

#a program that sums up 10 numbers#
#first we declare the array and sum and then use a for loop to create a case for each number in the array and
#add it to sum#

array = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
sum = 0
for x in array:
    sum = sum + x
print("The sum is " + str(sum))

#############
# here we have a WHILE loop that basically deletes the last digit of the number given and stores it in the array
# once the number reaches 0 it prints it out in reverse and then we use the reverse function to print it
# how it should be #
number = 3423
digits = []
while number > 0:
    digit = number %10
    digits.append(digit)
    number= number//10
digits.reverse()
print ("digits of the number 3423 are " + str(digits))

#Area of a triangle#

a = 3
b = 4
c = 5

#calculate the radius, then the area with Heron's formula#

s = (a + b + c) / 2

area = (s*(s-a)*(s-b)*(s-c)) ** 0.5

print ("The area of the triangle is", area)
#ta da#


#we need an empty array#
#then we create a range of numbers from which we want to extract the prime ones#
#for each number in our range we check if its devisible by the number smaller than the number checked (x)#
#if its devisible then its not a prime number#
#if we checked all smaller numbers and it isnt devisible by any and itnt devisible by and, its a prime and we add it
#to the array

primes = []
for x in range(2,100):
    flag= True
    for i in range(2, x):
        if x%i==0:
            flag= False
            break
    if flag:
        primes.append(x)
print ("the primes in the 1st 100 numbers are " + str(primes))




