Skip to content

Commit eb878a9

Browse files
committed
Merge pull request blakeembrey#154 from saurabhjn76/master
Added some solutions in python and c
2 parents 30d8dad + 585f286 commit eb878a9

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

solutions/c/multiples-of-3-and-5.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#include <stdio.h>
2+
3+
int sum_of_multiples(int n)
4+
{ int sum=0;
5+
n=n-1;
6+
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
7+
return sum;
8+
}
9+
int main()
10+
{
11+
printf("%d\n",sum_of_multiples(1000));
12+
return 0;
13+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
def plusOneSum(arr):
2+
"""returns the sum of the integers after adding 1 to each element"""
3+
return sum(arr)+len(arr)

0 commit comments

Comments
 (0)