It takes about minute to achieve 3000 in my comp but I need to know the millionth number in the series. The definition is recursive so I cannot see any shortcuts except to calculate everything before the millionth number. How can you fast calculate millionth number in the series?
Series Def
n_{i+1} = \floor{ 3/2 * n_{i} }
and n_{0}=2
.
Interestingly, only one site list the series according to Google: this one.
Too slow Bash code
#!/bin/bash
function series
{
n=$( echo "3/2*$n" | bc -l | tr '\n' ' ' | sed -e 's@\\@@g' -e 's@ @@g' );
# bc gives \ at very large numbers, sed-tr for it
n=$( echo $n/1 | bc ) #DUMMY FLOOR func
}
n=2
nth=1
while [ true ]; #$nth -lt 500 ];
do
series $n # n gets new value in the function through global value
echo $nth $n
nth=$( echo $nth + 1 | bc ) #n++
done