<commit_before><commit_msg>Added Happy number implementation<commit_after>-- Happy Number implementation
-- See: http://en.wikipedia.org/wiki/Happy_number

-- Utility function
-- Returns the sums of squares of the digits of a number n
local function sumsq(n)
	local ssq = 0
	for d in tostring(n):gmatch('%d') do
		local num_d = tonumber(d)
		ssq = ssq + num_d * num_d
	end
	return ssq
end

-- Checks if the given number is a happy number
-- n   : a number
-- returns : true if n is a happy number, false otherwise
return function(n)
	while n > 9 do
		n = sumsq(n)
	end
	return n==1
end
{'fraction_non_alphanumeric': 0.09572649572649573, 'fraction_numerical': 0.005128205128205128, 'mean_word_length': 3.4732824427480917, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7465514', 'n_tokens_mistral': 205, 'n_tokens_neox': 194, 'n_words': 79}