A very quick lash-up. I'm sure it can be simplified. I'll leave it to you to insert the 'maths' you require.
[{"id":"eb33aa15.9c8518","type":"inject","z":"8a9f04ff.2bbeb","name":"Start","topic":"","payload":"start","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":190,"y":200,"wires":[["8d16e77f.480b3"]]},{"id":"589fdea6.104618","type":"inject","z":"8a9f04ff.2bbeb","name":"Stop","topic":"","payload":"stop","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":190,"y":260,"wires":[["8d16e77f.480b3"]]},{"id":"e56cbc00.56df5","type":"inject","z":"8a9f04ff.2bbeb","name":"Reset","topic":"","payload":"reset","payloadType":"str","repeat":"","crontab":"","once":true,"onceDelay":0.1,"x":190,"y":100,"wires":[["195356b.fb27129"]]},{"id":"195356b.fb27129","type":"function","z":"8a9f04ff.2bbeb","name":"","func":"flow.set(\"counter\",0);\nflow.set(\"status\",\"stop\");","outputs":0,"noerr":0,"x":390,"y":100,"wires":[]},{"id":"8d16e77f.480b3","type":"function","z":"8a9f04ff.2bbeb","name":"","func":"if (msg.payload == \"start\") {\n flow.set(\"status\",\"start\");\n}\nelse if (msg.payload == \"stop\") {\n flow.set(\"status\",\"stop\");\n}\n","outputs":0,"noerr":0,"x":390,"y":220,"wires":[]},{"id":"8f2c92c5.7b4c18","type":"inject","z":"8a9f04ff.2bbeb","name":"","topic":"","payload":"1","payloadType":"num","repeat":"1","crontab":"","once":false,"onceDelay":0.1,"x":190,"y":360,"wires":[["fa23b6c6.f3b2a8"]]},{"id":"fa23b6c6.f3b2a8","type":"function","z":"8a9f04ff.2bbeb","name":"","func":"var status = flow.get(\"status\") || \"stop\";\nvar count = flow.get(\"counter\") ||0;\n\nif (status == \"start\"){\n msg.payload = count;\n count = count + 1;\n flow.set(\"counter\",count);\n return msg;\n}\nelse if (status == \"stop\") {\n msg.payload = count;\n return msg;\n}\n","outputs":1,"noerr":0,"x":390,"y":360,"wires":[["d548edbb.889458"]]},{"id":"d548edbb.889458","type":"debug","z":"8a9f04ff.2bbeb","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":570,"y":360,"wires":[]}]