15 votes

Paying off an installment

Using Annuity: pmt /.Solve[TimeValue[Annuity[pmt, 52, 1], .02, 0] == 5000, pmt] 155.545 ...
user avatar
  • 10.6k
13 votes
Accepted

How to calculate a list without loop?

Accumulate@Array[b, {3}] (* {b[1], b[1] + b[2], b[1] + b[2] + b[3]} *) therefore: ...
user avatar
11 votes
Accepted

A while loop that terminates after a number of seconds elapsed?

You could do something like this: tstart = SessionTime[]; While[(t = SessionTime[] - tstart) < 60, (* do stuff *)]
user avatar
  • 68.7k
10 votes

How to calculate a list without loop?

FoldList[{0, 1} # + #2 &, list]
user avatar
  • 83.3k
10 votes
Accepted

FixedPoint not working, despite quick convergence of sequence

$Version (* "13.0.1 for Mac OS X x86 (64-bit) (January 28, 2022)" *) The Possible Issues section of the ...
user avatar
  • 120k
8 votes

Paying off an installment

The general formula can be derived as follows. ...
user avatar
  • 58.3k
8 votes
Accepted

Recursion depth exceeded in pattern matching with attribute Flat

I find Flat hard to work with. Despite seeing it in use numerous times I'm never quite sure what it will do until I try it, so maybe I'm not the person to answer ...
user avatar
  • 264k
8 votes
Accepted

Why is this an infinite loop?

The loop is infinite, because the result of Append is the new list, not the modification of existing. Documentation: ...
user avatar
  • 3,807
7 votes

How do I limit the iterations in a while loop?

As an alternative to a manual check of the iterator, as proposed by Kuba, you could refactor to use NestWhile by converting your body and test to functions without ...
user avatar
  • 264k
7 votes
Accepted

ReplaceRepeated as a Looping construct?

Using the shortcut //. together with a MaxIterations options ...
user avatar
  • 27.1k
7 votes
Accepted

solve equation with loop

First off, don't use capital letters, you'll run into trouble like you did there (E is defined as the natural log unit $e$). You can do what you are going for with ...
user avatar
  • 62.7k
7 votes

solve equation with loop

...
user avatar
  • 108k
7 votes

avoiding writing loops

Total[DistanceMatrix[a]] ...too short to be an acceptable answer (minimum is 30 characters) without some meaningless commentary
user avatar
  • 14.7k
7 votes

How to populate a table with results from a while function

Use Sow and Reap : ...
user avatar
  • 11.5k
6 votes
Accepted

While loop repeats itself using initialization cell

Mathematica won't run it twice unless you (possibly unknowingly) instruct it to do so. I suspect this is what is happening (please update the question with the details): You put some initialization ...
user avatar
  • 224k
6 votes

For-loop doesn't work

First of all there is nothing like double in Mathematica, you don't need to define the type of variable here. I don't know what problem are you trying to solve, ...
user avatar
  • 1,568
6 votes
Accepted

Infinite While loop

The crux of the matter is how n is changed on each iteration. Math Consider a multi-digit integer $n = a_1 a_2 a_3 \ldots a_N$, where $a_k$ is the $k$-th digit of ...
user avatar
6 votes
Accepted

Generating trigonometric sums

n = 10; basis = Table[Cos[k t], {k, 0, n}]; Tuples[{-1, 1}, n + 1].basis
user avatar
5 votes

Looping things in Mathematica

As alluded to by Daniel Lichtblau you could use TriangleWave with appropriate scaling, e.g. ...
user avatar
  • 55k
5 votes
Accepted

Open a pop up window that runs a calculation in loop until it is closed?

Simon's code ...
user avatar
5 votes

How to calculate a list without loop?

thanks to Mike Honeychurch, without pure function: ...
user avatar
  • 4,735
5 votes
Accepted

How to check keys and values in nested Associations?

This solution will traverse all nested associations regardless of depth and replace each value with the value that corresponds to its key in replacements. ...
user avatar
  • 68.7k
5 votes
Accepted

Check every list element for appearance

All you need is to do Map MemberQ over the second column (a.k.a. [[2]]) of each lines: <...
user avatar
  • 8,417
5 votes
Accepted

Coding `While` loops

Something like this: ...
user avatar
  • 68.7k
5 votes
Accepted

Paying off an installment

Just to show how to fix the origional loop: ...
user avatar
  • 38.3k
5 votes

Paying off an installment

Using the example for an ordinary annuity from here:- Calculating The Present And Future Value Of Annuities The example demonstrates how a present value principal of 4329.48 is paid down by five ...
user avatar
  • 29.2k
5 votes

A while loop that terminates after a number of seconds elapsed?

An example using TimeConstrained: ...
user avatar
  • 6,373
4 votes

Minimize loop optimization

I'm not sure exactly what you want, but in an effort to demonstrate some possibilities: ...
user avatar
  • 264k
4 votes

Solving a trigonometric equation with one parameter

Setting b = 1 from the start, your equation can be rewritten as (3 k)/(3 + a k^2) == Tan[k] This has multiple solutions for <...
user avatar
  • 5,921
4 votes

Problem with recursion depth

You define L1 in terms of L1, which leads to a recursion. A much simplified but completely analogous example is ...
user avatar
  • 224k

Only top scored, non community-wiki answers of a minimum length are eligible