CSH 1.4 Algorithms

2975 days ago by CSH2012

#1) balancing equs, adding integers, dividing decimals 
       
#2) def s(n): return n*(n+1)/2 print(s(1)) print(s(2)) print(s(3)) print(s(4)) print(s(5)) 
       
1
3
6
10
15
1
3
6
10
15
#3) 17/5 = 3 because adding 3 5s is less than 17, but 4 5s is too big #3) 17%5 = 2 because 3 5s = 15 and 17 - 15 = 2 #3) 19/3 = 6 because adding 6 3s is less than 19, but 7 3s is too big #3) 19%3 = 1 because 6 3s is 18 and 19 - 18 = 1 
       
#4) 3^4 = 81 because multiplying 3 by itself 4 times is 81 
       
#5) findK(12) = 3 b/c mult 2 by itself 3 times is 8, but 4 times is too big 
       
#6) find1st("school", "scat") = "scat" #6) if word1[2]<word2[2] then word1 comes first #6) else word2 comes first