All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars    
perplexus dot info

Home > Just Math
Sum Divisibility Dilemma (Posted on 2014-03-18) Difficulty: 3 of 5
Determine a general formula (in terms of n) for the sum of the first n positive integers that are not divisible by 5.

No Solution Yet Submitted by K Sengupta    
No Rating

Comments: ( Back to comment list | You must be logged in to post comments.)
Some Thoughts solution | Comment 4 of 6 |

I see that the below "solution" misinterprets what is asked. It has the sum of the first n positive integers minus the multiples of 5:

n*(n+1)/2 - [n/5]*([n/5] + 1)*5/2

where [ ] represents the floor function.

To test it:

DEFDBL A-Z
CLS
FOR n = 1 TO 45
    PRINT n, n * (n + 1) / 2 - INT(n / 5) * (INT(n / 5) + 1) * 5 / 2
NEXT

n             sum
1             1
2             3
3             6
4             10
5             10
6             16
7             23
8             31
9             40
10            40
11            51
12            63
13            76
14            90
15            90
16            106
17            123
18            141
19            160
20            160
21            181
22            203
23            226
24            250
25            250
26            276
27            303
28            331
29            360
30            360
31            391
32            423
33            456
34            490
35            490
36            526
37            563
38            601
39            640
40            640
41            681
42            723
43            766
44            810
45            810

Edited on March 18, 2014, 3:19 pm
  Posted by Charlie on 2014-03-18 15:10:39

Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


Search:
Search body:
Forums (0)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (0)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

Chatterbox:
Copyright © 2002 - 2024 by Animus Pactum Consulting. All rights reserved. Privacy Information