(1) Perform the followings.
select set_seed(1);
prepare calculate_pi as select 4 * (count(*)::float8 / $1) from (select random() as x, random() as y from generate_series(1,$1,1)) a where ((x * x) + (y * y) < 1);
execute calculate_pi(100);
execute calculate_pi(1000);
execute calculate_pi(10000);
execute calculate_pi(100000);
execute calculate_pi(1000000);
execute calculate_pi(10000000);
execute calculate_pi(100000000);
(2) I got the following outputs.
3.04
3.104
3.1296
3.13724
3.142204
3.1421488
3.14156916