Hi, one way to do it is by sieve's technique but is there any other method?
With any method, since there is always at least one prime between N and 2N, start from N and decrement, when you reach N/2. if N is prime, you save time. in this case the largest prime lesss than N is 1.
If N is large, the divide test will be tedious. Use a primalty test (Rabin, or Lucas or else. It will be much faster