Rabbinatix
Sign inGet started
Store

Split a bill

FreeLogic
@rabbinatix/split-a-bill by Rabbinatixupdated Oct 4, 2026

Splits an amount in cents fairly: 10.00 for 3 is 3.34 + 3.33 + 3.33.

Sign in to add

Everyone pays the whole-cent share; the cents left over go one each to the first people, so the shares always add up to the total. Works in cents to avoid rounding errors.

Shows: For Loop, a list Variable built with Set Variable and Append, Round Down, Modulo, Less or Equal, Select.

How to use it

Add it to your logic, then add a Call Function step in any logic and pick Split a bill. It belongs to no system, so every system can use it. Or download the TypeScript and call it from your own code.

Inputs
totalCents: Whole number
people: Whole number
Outputs
shares: List of whole numbers
Previewdrag the steps around; scroll to zoom
Function Entry, Input / output. 0 inputs, 3 outputs. step 1 of 13
Split a bill
totalCents
people
For Loop, Flow control. 3 inputs, 3 outputs. step 2 of 13
For Loop
first
last
Loop Body
index
Completed
Divide, Operators. 2 inputs, 1 output. step 4 of 13
/
A
B
result
Round Down, Math. 1 input, 1 output. step 5 of 13
Round Down
value
result
Modulo, Operators. 2 inputs, 1 output. step 6 of 13
%
A
B
result
Less or Equal, Operators. 2 inputs, 1 output. step 7 of 13
<=
A
B
result
Select, Data. 3 inputs, 1 output. step 8 of 13
Select
condition
if true
if false
value
Add, Operators. 2 inputs, 1 output. step 9 of 13
+
A
B
result
Get Variable, Data. 0 inputs, 1 output. step 3 of 13
Get shares
value
Append, Collection. 2 inputs, 1 output. step 10 of 13
Append
array
item
result
Set Variable, Data. 2 inputs, 2 outputs. step 11 of 13
Set shares
value
value
Get Variable, Data. 0 inputs, 1 output. step 12 of 13
Get shares
value
Return, Input / output. 2 inputs, 0 outputs. step 13 of 13
Return
shares

Arrow keys: next or previous step in flow order. Alt with arrows: nearest step in that direction. Enter: open. Shift F10: more actions.

100%
Examplesrun live against the logic · 2/2 pass
PassedExampleInputOutput
Cents left over{"totalCents":1000,"people":3}{"shares":[334,333,333]}
Even split{"totalCents":900,"people":3}{"shares":[300,300,300]}
Try it
Versions
In this package
Split a bill (entry)