How to correctly transfer the code from the blueprint to the material?

Help transfer the blueprint code to the material!
The code is a conversion of the hsi color model to rgb.
This is working code in the blueprints, and also my attempt to translate this into materials that don’t work right!
Please see what I did wrong, conditions, sequence, etc.:

Primary colors red, green and blue and again red are in their places respectively:
Red - 0
Green - 120
Blue - 240 and again red - 360.
In between should be yellow, cyan and magenta, and I have white!
Even if you check each rgb output separately, it turns out nonsense, for example C, X, 0 - should give a gap from red to red and yellow in between, but for me Red - White - Red

Hoping for someone’s help thanks!