I have julianday like 731831, how i can get day of year from it?
That's a rather low Julian Day Number.
And remember that days start when the fractional part of the JD is .5
If you plug 731831 into the USNO's converter it gives
BCE 2710 August 24 12:00:00.0 UT Wednesday
In other words noon on a Wednesday.
I just wonder if the ancient people of that time thought of it as Wednesday?
This is very much a solved problem. Your best bet is to get a library where someone else wrote and debugged the code for you.
If you can use Python, here is a simple example: http://katamari.ssec.wisc.edu/resources/scriptonomicon/julian-day-to-calendar-day
If you really want to write it yourslelf, I suggest a Google search for "Julian conversion algorithm". I ran that search and here is a good result: http://www.hermetic.ch/cal_stud/jdn.htm#comp