* Investors more confident Slovenia can avoid bailout
* External audit to determine recap needs
* Slovenia can tap markets, 'bail-in' creditors, use deposits
* Government takes heart from private bond placement
LJUBLJANA, Nov 25 (Reuters) - Whichever way you do the maths, Slovenia is in trouble.
But the mood among investors visiting the former Yugoslav republic has suddenly brightened, buoyed by a private bond placement last week that was snapped up by a mystery buyer.
Coupled with talk of a 'bail-in' of junior bank bond holders, confidence is growing that Slovenia can avoid becoming the latest euro zone state to seek an international bailout.
The number-crunching has intensified as Slovenia and its European partners await the results next month of an external audit of its teetering banks, which will determine how much cash the government must inject to keep them afloat.
Under the worst-case scenario, outlined by rating agency Fitch, Slovenia will have to recapitalise its mostly state-owned banks with 4.6 billion euros ($6.2 billion) - far more than the 1.2 billion euros it has set aside.
But the government still has a few tricks up its sleeve.
"It is quite possible that the stress tests will show that the banks need more than 3 billion euros of fresh capital," said a source close to the government, who declined to be identified.
"But even in case the figure would reach as much as 4.6 billion, as estimated by Fitch, we would still be able to finance it ourselves."
In a note last week, Eurasia Group said it expected Slovenia to get by on its own, "through market financing, partial use of its EUR 3.6 billion capital provisions, and if need be, by burning shareholders and junior creditors".
Analysts estimate a bail-in of holders of subordinated bank debt would yield around 500 million euros.
The government's own cash deposits with the central bank and commercial banks, confirmed for Reuters by the Finance Ministry on Monday at 5 billion euros, could also help cover the banking system's capital needs. Analysts say the government could use around 3 billion euros of those deposits.
Otilia Dhand, vice president of London-based consultancy Teneo Intelligence, said Slovenia might still have to borrow some 2 billion euros, but "that could probably be feasible".
The government improved its position last week when it sold a three-year, 1.5 billion euro bond with an interest rate of 4.7 percent to a sole buyer whose identity is still not known.
"The government will try to access the markets if possible and will only resort to the bailout if absolutely necessary," said Dhand, who visited Slovenia last week.
The bond issue came just hours after the coalition government won a parliamentary confidence vote, a boost for Prime Minister Alenka Bratusek as she wrestles with worst financial crisis since Yugoslavia's bloody breakup in the 1990s.
Hailed as a trailblazer for ex-Communist Eastern Europe, Slovenia - which nestles between Croatia, Italy and Austria - joined the European Union in 2004 and the euro in 2007.
But the global financial crisis a year later crippled the country's vital export markets, and bad loans at Slovenia's banks have since spiralled to almost 8 billion euros, equivalent to more than a fifth of national output.
A new 'bad bank' is due to absorb around 4 billion euros of those bad loans, starting after the stress test results.
"(This) series of events has significant implications for our outlook on Slovenia," Royal Bank of Scotland emerging market strategist Abbas Ameli-Renani, who recently visited Slovenia, said of the private bond placement and the confidence vote.
"Government funding is substantially improved after the private placement and we now estimate that the government has a fiscal buffer of at least 5 billion euros.
"We see the chances of the government having to seek an international bailout to be slim," he said.
The government has declined to comment on the size of the possible bank recapitalisation, although its tone has become more positive. The yield on Slovenia's 10-year benchmark bond has meanwhile fallen to its lowest since late March, hitting 5.687 percent last week.
"Over the past 14 days the probability that we will be able to solve all problems by ourselves is much greater than it was before," central bank governor Bostjan Jazbec said on Friday.
But the risk Slovenia will need a bailout remains.
Saso Stanovnik, chief economist of Ljubljana-based Alta Invest, said the bond sale and previous savings should allow the government to cover the banks' capital needs without a bailout - unless the sum required tops 4.5 billion euros.
Slovenia could then ask for support for its banks from the euro zone's ESM rescue fund, or follow Greece, Ireland, Portugal and Cyprus in seeking a national bailout from the European Union, European Central Bank and International Monetary Fund.
The latter would come with strict conditions and monitoring, a politically more painful route. Although tiny compared with the more than 200 billion euros poured into Greece, a bailout of Slovenia would come at a political price for Europe, too.
It would revive concerns over the bloc's ability to put its debt crisis to rest and further test the patience of the euro zone's chief paymaster, Germany.
"There is very little support in Slovenia as well as in key EU players (such as Germany) for a Slovenia programme, even if limited to banks and not the broader sovereign," said Tsveta Petrova, Europe analyst at Eurasia Group.