What is "!" | Sololearn: Learn to code for FREE!
Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок
+ 1

What is "!"

So i am currently doing some exercices in Java and i have this formula "S = 1 + 1!/x + 2!/x^2 + .... + N!/x^N " soo my question is what are those !-s before / ? Thanks in advance :)

1st Apr 2018, 7:51 PM
ZoBe
ZoBe - avatar
4 ответов
+ 9
In math ! is factorial. 5! = 1 * 2 * 3 * 4 *5 3! = 1 * 2 * 3
1st Apr 2018, 7:57 PM
Alex
Alex - avatar
+ 4
In programming the ! has another meaning. In your code it means "not". It's used to negate boolean values or to compare 2 values (!= means "is not") To calculate the factorial you need to make a function for it where you pass the number in and get the result back. The result then gets used in the formula
1st Apr 2018, 8:14 PM
Alex
Alex - avatar
+ 3
Hint: The first part of the formula (1) is actually 0! / x^0
1st Apr 2018, 8:15 PM
Alex
Alex - avatar
+ 2
Thank you :)
1st Apr 2018, 8:18 PM
ZoBe
ZoBe - avatar