0.1 M solution of weak acid has pH=4.0. Calculate pKa.
If pH=4.0 then [H+]=10-4 - that means that the dissociation fraction is about
10-4/0.1×100%=0.1% - well below 5%. That in turn means that pH of the solution is described reasonably accurately by the simplified formula 8.13:

All we have to do is rearrange to get the equation for Ka:

Plugging numbers in we get Ka=(10-4)2/0.1=10-7, so pKa=7.
Our pH calculator can help us check this result - and indeed, entering 0.1 as concentration and 7 as pKa we get pH=4.0 which confirms our calculations.