How do you generate all numbers divisible by 13 between 1 and 100 in Appian?
How do you generate all numbers divisible by 13 between 1 and 100 in Appian?
Answer
Appian Code:
Explanation
Above appian expression returns every number from 1 to 100 that is divisible by 13. It builds the list, tests each number, and drops the ones that fail.
1. Generate the numbers
enumerate(100) returns the integers 0 to 99. Adding 1 moves the list to 1 to 100.
2. Loop over the list
a!forEach() runs the expression once for each number in the list, and fv!item is the current number.
3. Test for divisibility
mod() returns the remainder after division. A remainder of 0 means the number divides evenly by 13.
4. Keep matches, null out the rest
A number divisible by 13 is returned as is. Any other number becomes null().
5. Remove the nulls
reject() drops every value that passes the fn!isnull test, so only the numbers divisible by 13 remain.
Output:
Solution 2 - Find Numbers Divisible by 13 Using Sequence Arithmetic
Appian Code
Explanation
enumerate(7)returns the integers 0 to 6.- Multiplying by 13 gives
{0, 13, 26, 39, 52, 65, 78}. - Adding 13 moves the list up one step, to
{13, 26, 39, 52, 65, 78, 91}.
Output
This builds the multiples directly, with no loop and no filtering. It works because exactly seven multiples of 13 fall between 1 and 100, so enumerate(7) gives the right count.
Try it yourself
Change the inputs or the expression and run it to see what it returns.
Independent evaluator: it approximates the Appian expression language and may differ from a real Appian environment. Verify anything that matters. Terms