# Tag Info

1

s[n_] := Reap[ NestList[ Sow[{#[[1]] + 1, 7 #[[2]] + #[[1]]}, FreeQ[IntegerDigits[7 #[[2]] + #[[1]]], 7]] &, Sow[{1, 1}, True], n], True][[2, 1]]; So for the first 100 members of sequence 11 comply: Grid[Prepend[s[100], {"n", "a[n]"}]]

1

The LinearProgramming[...] solution. Recall the canonical minimization form for linear programming: \begin{align} \mathrm{minimize}\ \mathbf{c}^\mathrm{T}\mathbf{x} \ \mathrm{subj\ to:\\} \mathbf{Ax}\ge \mathbf{b} \mathrm{\ and \ } \mathbf{x\ge0} \end{align} In the interest of keeping this answer simple and informative, we can throw out the nonlinear ...

2

data returns: {114.754, {tomatoe -> 1.72651*10^-8, lettuce -> 0.58548, spinach -> 3.53893*10^-8, carrot -> 8.48321*10^-9, sunflower -> 9.69807*10^-10, tofu -> 0.87822, chickpea -> 3.3596*10^-9, oil -> 4.43666*10^-10}} Where 114.754 is the minimum total energy with the constraints you have given. ...

1

Just use the following instead of your print statement: Print[cost[tomatoe, lettuce, spinach, carrot, sunflower, tofu, chickpea, oil] /. data[[2]] ] (* Out: 2.32728 *) The Minimize function returns the following data structure: {114.754, {tomatoe -> 1.72651*10^-8, lettuce -> 0.58548, spinach -> 3.53893*10^-8, carrot -> 8.48321*10^-9, sunflower -> ...

0

fun[n_] := Reap[NestList[Sow[3 # + 7, FreeQ[IntegerDigits[3 # + 7],5]] &, Sow[6, True], n],True][[2, 1]] This will produce the numbers that comply,e.g. fun[10]: {6, 82, 766, 6922, 20773, 62326} If the n is desired: funq[n_] := Reap[NestList[ Sow[{#[[1]] + 1, 3 #[[2]] + 7}, FreeQ[IntegerDigits[3 #[[2]]+7],5]] &, Sow[{1, 6}, ...

6

The recurrence equation can be solved analytically Clear[a] a[n_] = a[n] /. RSolve[ {a[n + 1] == 3 a[n] + 7, a[1] == 6} , a[n], n][[1]] (1/6)*(-21 + 19*3^n) Generate a sufficiently long starting list, Select numbers that do not contain the digit 5, and Take the first five elements of the remaining list. Take[ Select[ Table[{n, ...

8

Your formula should be either 4 + Sum[(-1)^x*4/(2*x + 1), {x, 1, Infinity}] Pi or Sum[(-1)^x*4/(2*x + 1), {x, 0, Infinity}] Pi The finite series approximation is then Clear[f] f[n_] := Sum[(-1)^x*4/(2*x + 1), {x, 0, n}] As n increases, f[n] converges slowly to Pi. With[{nmax = 150}, DiscretePlot[f[n], {n, 1, nmax}, Epilog -> {Red, ...

3

An interesting problem which at first sight looks innocent. But then ... My (bold) conjecture is that the maximum number lg of terms you can get of this recurrence if a[1] == 1 is lg = 11. First we solve the recurrence explicitly sol = RSolve[a[n + 1] == 7 a[n] + n && a[1] == 1, a[n], n]; a[n] /. First[sol] (* Out[317]= 1/252 (-7 + 43 7^n - 42 ...

1

I don't have Mathematica to test this, but I think something like this ought to work: Block[{n = 10, k= 0}, NestList[NestWhile[(k++; 7 # + k) &, #, DigitCount[#, 10, 7] != 0 &, {2, 1}] &, 1, n]]

2

This is mostly a copy and paste of the brilliant answer by @WReach regarding implementation of lazy lists in Mathematica. I'll refer you to that answer for a detailed explanation of his concept of a stream and only detail the modifications I made for this particular problem. ClearAll[stream] SetAttributes[stream, {HoldAll, Protected}] sEmptyError[] := ...

Top 50 recent answers are included