diff --git a/app/src/main/kotlin/com/simplemobiletools/calculator/operation/FactorialOperation.kt b/app/src/main/kotlin/com/simplemobiletools/calculator/operation/FactorialOperation.kt new file mode 100644 index 00000000..c3dd3131 --- /dev/null +++ b/app/src/main/kotlin/com/simplemobiletools/calculator/operation/FactorialOperation.kt @@ -0,0 +1,26 @@ +package com.simplemobiletools.calculator.operation + +import com.simplemobiletools.calculator.operation.base.BinaryOperation +import com.simplemobiletools.calculator.operation.base.Operation +import com.simplemobiletools.calculator.operation.base.UnaryOperation + +class ParOperation(value: Double) : UnaryOperation(value), Operation { + + override fun getResult(): Double { + var result = 1.0 + if (value==0.0 || value==1.0){ + return result + } + else { + var base: Int + base = value.toInt() + for (i in 1..base){ + //Find Factorial of a number using for loop + result *= i + + } + } + return result + + } +} \ No newline at end of file