Numbers that are comprised of all 1's in binary expansion

I have to find a number that is made of 1's only (i.e. 111, 1111, 1111111, not 1010, 11101, 1101010, etc) that is a multiple of 17. I have to find the smallest number that meets this requirement

The forumula 2^(n+1) - 1 = 17p was set up to solve this problem since the numbers

1, 3, 7, 15, 31 put into binary expansion are all made of 1. If you didnt notice, the term n is created by multiplying the previous term by 2 and adding 1.

I found the answer using a java program and n = 7 and p = 15. Any mathematical way to solve it?