From 4b98301001d0e278bc1657253a68fca75134fe04 Mon Sep 17 00:00:00 2001 From: Saurabhjn Date: Fri, 25 Sep 2015 23:57:29 +0530 Subject: [PATCH 1/2] Added solution to sum-of-array-plus-one in python --- solutions/python/sum-of-array-plus-one.py | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 solutions/python/sum-of-array-plus-one.py 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 From 8316198072faeaec2ca0c29a8693ff1e9320d5fd Mon Sep 17 00:00:00 2001 From: Saurabhjn Date: Sat, 26 Sep 2015 00:25:42 +0530 Subject: [PATCH 2/2] Added solution to multiples-of-3-and-5 in C. --- solutions/c/multiples-of-3-and-5.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 solutions/c/multiples-of-3-and-5.c 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