Time of acceleration is the key to the calculations, for Newton's second law to apply. Time of flight being for the projectile exiting the muzzle.
Applying f=ma for this time results in the energy transfer. Using the average acceleration and time one can calculate the average force applied.
Whatever that value (it matters not) because applying that same force, whatever it might be, to a large inertial body (mass of gun) will provide the average acceleration for the given time. Because the gun is so much more massive, the final velocity will be so much smaller than that of the bullet. Because the energy in Joules is proportional to both the mass and velocity squared, the energy of the bullet will be far higher due to the velocity squared part of the calculation.
Firing shotgun cartridges outside the gun normally results in the case splitting. So the burn energy is dissipated sideways through the split. Furthermore, the burn rate is far diminished because there is little pressure build-up. In the case of a steel cased bullet, things are not quite so benign. Pressure build-up rate can result in far higher pressure before the bullet is discharged from the case.
Not anywhere near as high velocities, of course (time of acceleration is short), but there is the possibility of lethality, all the same, at close range. Depends if the bullet and case fly apart in opposite directions or if the case bursts. Not something to try. Years ago, many .303 bullets were fired by the village lads by sticking the bullet in a crevice and firing them off with an airgun touching the primer. They certainly carried a punch! I've fired cartriges stood on the end of an airgun, but never tried to fire a .303 that way.
At junior school in the 1950s we used to make long cordite or gunpowder trails around the playground and light them off at the end of the playtime. There were plenty of live ammo around in those days. It was not until about 1973, when the army disposal teams were enlightened to our local ammo dump (after a WWII practice mortar bomb killed a lad who found it, took it home and was told to take it away), that the area was cordoned off and cleaned up. I also know that a Stirling sub machine gun was thrown in a pond where I lived. The 'easier' days of the black home guard cartriges. Certainly lethal when used to blow carrion crow's nests out of high trees from a good distance. Dad only used his best gun, and the open choke, for those cartridges!