New answers tagged

0

Clear[getDigit] ; getDigit[number_,position_] := Mod[Quotient[number,10^(position-1)],10] ; num = 5467 max = Ceiling[Log10[N[num]]] ; getDigit[num,max+1-3] num = FromDigits[Range[9]] max = Ceiling[Log10[N[num]]] ; getDigit[num,max+1-5]


3

This my program is based also on PrimeZetaP, but is much faster. $MaxExtraPrecision = 1000; Clear[f]; f[p_] := (1 - 1/(p*(p + 1))); Do[c = Rest[CoefficientList[Series[Log[f[1/x]], {x, 0, m}], x]]; Print[f[2] * Exp[N[Sum[Indexed[c, n]*(PrimeZetaP[n] - 1/2^n), {n, 2, m}], 100]]], {m, 100, 1000, 100}] (* 0....


0

g[x_ /; x <= 9] := x g[x_ /; x > 9] := Floor[x/2]   Most@FixedPointList[g,500] {500, 250, 125, 62, 31, 15, 7}


4

You can also use FixedPointList ClearAll[quotients1] quotients1[n_, k_] := Most @ FixedPointList[If[IntegerLength[#] > 1, Quotient[#, k], #] &, n] Examples: quotients1[100, 2] {100, 50, 25, 12, 6} quotients1[950, 3] {950, 316, 105, 35, 11, 3} ReplaceRepeated ClearAll[quotients2] quotients2[n_, k_] := {n} //. {a___, b_} /; ...


5

One way might be NestWhileList[Floor[#/2] &, 100, Length[IntegerDigits[Floor[#]]] > 1 &] (* {100, 50, 25, 12, 6} *) NestWhileList[Floor[#/2] &, 500,Length[IntegerDigits[Floor[#]]] > 1 &] (* {500, 250, 125, 62, 31, 15, 7} *) Or if you prefer to code it yourself foo[n_Integer, k_Integer] := Module[{z}, If[k == 0, Return["Error k=...


Top 50 recent answers are included