(need help coding) making a square wave generator 30 to 1MHz

An Arduino runs at 16 MHz clock; that's the resolution of frequency you can get.

1 MHz is no problem.

1,000,001 Hz doesn't work. But do you really need that kind of steps?