Euler's totient function counts the positive integers up to a given integer [i]n[/i] that are relatively prime to [i]n[/i].[br][br][b]Note:[/b] It works for n < 10[sup]14[/sup]-1
This version uses only GGb scripting, but here is another version with JavaScript:[br][br]https://www.geogebra.org/m/sg2njyd5
n = 123456[br]Inp = InputBox(n)[br]SetCaption(Inp, "n = ")[br][br]facts = Factors(n)[br][br]phi = If(n <=0 , ?, If( n == 1, 1, Product(Sequence(Element(facts, i, 1)^(Element(facts, i, 2) - 1) (Element(facts, i, 1) - 1), i, 1, Length(facts))) )[br][br]text = "\phi(n) = " + phi
n = 123456[br][br]Inp = InputBox(n)[br]SetCaption(Inp, "n = ")[br][br]F = Unique(PrimeFactors(n))[br][br]phi = If(n<=0, ?, If(n == 1, 1, n Product(Zip(1 - 1 / p, p, F))))[br][br]text = "\phi(n) = " + phi
Script improved with the help of [url=https://www.geogebra.org/m/ng2w82yh]Thijs[/url].