Make a program/function which takes in an integer from 0 to 999999999999 (inclusive) as input and returns how many syllables it has when spoken in English. Make your code short.
- A billion is a thousand million, a trillion is a million million, etc.
- A million has three syllables -- it's mill-ee-on, as opposed to mill-yon. Pronounce all -illions like this.
- Numbers like 1115 are 'one thousand, one hundred and fifteen'. The 'and' counts as a syllable.
- 0 is zero. That's two syllables.
I know the specification seems mishmash in terms of which standards are used (British or American, mainly) -- it's what I and everyone I know use. I would change it so it's consistent, but someone's already answered...
> 0 2 (zero) > 100 3 (one hundred) > 1000001 6 (one million and one) > 1001000001 10 (one billon, one million and one) > 7 2 (seven) > 28 3 (twenty-eight) > 78 4 (seventy-eight) > 11 3 (eleven) > 1111 10 (one thousand, one hundred and eleven) > 999999999999 36 (nine hundred and ninety-nine billion, nine hundred and ninety-nine million, nine hundred and ninety-nine thousand, nine hundred and ninety-nine)