Comments
0

Yes, you are right, but you need to turn the number(n) given to us, and only then calculate according to the scheme. After, reverse result and transfer to the decimal numeral system. Read this article: https://en.wikipedia.org/wiki/Toffoli_gate

В общем почитайте статью https://en.wikipedia.org/wiki/Toffoli_gate (есть на русском). Надо тип перевести n в 2-ую систему счисления, перевернуть число, посчитать по схеме, потом перевернуть результат и перевести в 1-ую систему