diff --git a/solutions/c/multiples-of-3-and-5.c b/solutions/c/multiples-of-3-and-5.c new file mode 100644 index 0000000..6e60cfc --- /dev/null +++ b/solutions/c/multiples-of-3-and-5.c @@ -0,0 +1,13 @@ +#include + +int sum_of_multiples(int n) +{ int sum=0; + n=n-1; + sum=((n/3)*((n/3)*3 +3))/2 + ((n/5)*((n/5)*5 +5))/2 - ((n/15)*((n/15)*15 + 15))/2; // sum of airthmetic progressions & De-Morgan's Law + return sum; +} +int main() +{ + printf("%d\n",sum_of_multiples(1000)); + return 0; +} \ No newline at end of file diff --git a/solutions/python/sum-of-array-plus-one.py b/solutions/python/sum-of-array-plus-one.py new file mode 100644 index 0000000..16490e5 --- /dev/null +++ b/solutions/python/sum-of-array-plus-one.py @@ -0,0 +1,3 @@ +def plusOneSum(arr): + """returns the sum of the integers after adding 1 to each element""" + return sum(arr)+len(arr) \ No newline at end of file