Making something out of nothing

This week’s Fiddler is a problem about composing functions. Here it goes:

Consider $f(n) = 2n+1$ and $g(n) = 4n$. It’s possible to produce different whole numbers by applying combinations of $f$ and $g$ to $0$. How many whole numbers between $1$ and $1024$ (including $1$ and $1024$) can you produce by applying some combination of $f$’s and $g$’s to the number $0$?

Extra Credit: Now consider the functions $g(n) = 4n$ and $h(n) = 1−2n$. How many integers between $-1024$ and $1024$ (including $-1024$ and $1024$) can you produce by applying some combination of $g$’s and $h$’s to the number $0$?

My solution:
[Show Solution]

Leave a Reply

Your email address will not be published. Required fields are marked *