We (my co-workers and I) ask people to write some code, or, at least, show us some code that they have written. Why? Because we've hired too many people who, when they actually showed up, lacked the capacity to do independent work. (It's also possible that they simply lied and padded their resumes, but I'd prefer to give them the benefit of the doubt; they really did 'contribute' to the things they described in interviews, but they were somehow never called upon to take the initiative and see something through.)
Typically, we would expect a task like this to take about a day.
I know that many of my peers in the CTO business feel the same way. I know that a number of large, famous, companies, do the same, or more so.
No one I know has ever 'gotten free work' this way; for one thing, the candidate retains copyright, and could sue our pants off. Of course, I am sure that sleazy people are out there; but, legally, it's not a work for hire, or any other sort of contract, without 'consideration', so anything you do for free belongs to you.
So, I'd strongly advise you not to say 'no', but rather to consider some combination of reconsidering the task or asking more questions about it. Saying no without any discussion is pretty much walking away from the opportunity; you don't need help from anyone else to do that.
If the task seems unreasonably large, you have to start by considering the possibility that the people who assigned it don't think it's such a big job. Over-engineering a task will not make you an attractive candidate. Ask them how long they expect it to take. Ask them how far down they want you to get into the details. Don't just dig in and spend a week.
It's also possible, sadly, that the scale of the task as you see it is telling you something about your fit for the job. They may be looking for a cowboy who will shoot something from the hip, while you might be a super-skillful watchmaker. Again, best to talk to them; why spend two days in a process of proving yourself unqualified?
Finally, I can't emphasize enough the value of having a body of work on github; we can read the code, run the code, and even examine the commit history if we have any doubt about who wrote it. If someone really does expect you to do a big audition, having a pre-existing audition piece gives you a reasonable way to avoid spending all that time. If they won't take it, maybe they are unreasonable people you don't want to work for?