Adding FactorialOperation class

This commit is contained in:
Sissy Dalampira 2018-10-04 21:23:40 +03:00
parent 726e0ac55f
commit 88565fc748
1 changed files with 26 additions and 0 deletions

View File

@ -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
}
}