Mathematical Range Summing

Immediately after the last post about summing a range of numbers, a talented friend of mine, Gábor, offered an even shorter, cleverer solution:

What I especially like about it is that instead of relying on esoteric JavaScript functions to do the job, it’s done with reasoning and plain maths, which makes it clearer and easier to read too.

The Maths.abs() call is only needed because in the original problem, the arguments could be in either order; the logic is still the same though, you just need to make sure the range is positive. In short, it’s (a+b) × (a-b+1) ÷ 2.

Sum All Numbers in a Range

A solution to Free Code Camp’s “Sum All Numbers in a Range” JavaScript challenge, in a Functional Programming style.

A friend of mine hosts meetups for the Free Code Camp, which describes itself as:

We’re an open source community of people who learn to code and help nonprofits.

He organises casual meetings in coffee shops to allow participants to work on their assignments in a nice environment and help each other. If you’re looking to learn programming I recommend finding a Free Code Camp group in your area.

Today I visited such a meeting and one of the Code Campers was working on a solution for one of the JavaScript problems in the Intermediate Algorithm Scripting section. The task was to write a function that takes an array of 2 numbers as an argument and returns the sum of all the numbers between them, including the 2 numbers themselves. For example, an input of [3, 1] should result in 6, because 1 + 2 + 3 = 6. As a hint, it’s recommended you read the documentation for Math.min(), Math.max() and Array.prototype.reduce(). Continue reading →

International Christian Fellowship of Budapest

ICFB LogoI joined the International Christian Fellowship of Budapest (ICFB) not knowing what to expect. Admittedly, having never been part of any kind of “Christian Group” before, initially I had my doubts. I was more of a quiet Christian, striving to show kindness but rarely talking to another person about Christianity. So it was with hesitation that I told Berni I’d join her to visit a group for Christians, which her friend Eszter had invited her to.

On the way home that Friday, chatting about plans for the weekend, my friend Attis told me the reason he’s got his guitar with him is because he’s on the way to an international Christian meet-up for students and young professionals, and asked me if I’d like to come along. This sounded cool and I like spontaneity but I’d already set plans for the evening with Berni. Of course it didn’t take long before we figured out we’d both been invited to the same event; I laughed all the way there.

I’ve been participating in ICFB’s Friday meet ups for almost three years now. I love the group and I’ve made some good friends there. My favourite part is singing together, so I always bring a guitar with me. I’d say even among other IFES groups in Hungary we’ve made a name for being lively and singing with spirit.

Árpád's map

Árpád’s map


The most important part of ICFB, after the C, is I: International isn’t just in the name. Our group is made up of people from countries all over the world. Árpád has a map of the world in his garden with names painted on to show where people he’s met are from. In a similar way, of all the songs we sing, my favourite is when we sing “How Great Is Our God” and everyone takes a turn singing the chorus in their own language.

However, we don’t just sing and we don’t just meet on Fridays. People often come sharing verses, insights or personal questions that make for good discussion. In good weather we might meet in parks on weekends and sometimes I bring my rugby ball to share a bit of my culture through touch-rugby.

That’s just me though; everyone has their own personal part in ICFB that makes it special for them and even though we’re all so different we all have one thing in common.

This was originally written as a guest post for mekdsz, the Hungarian evangelical Christian student fellowship. You can read their Hungarian translation here:
A nemzetközi helyzet tovább fokozódik.