Archived
1
This repository has been archived on 2022-08-08. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
mathpad/MathKit/MPFactorialTerm.m
2015-01-04 22:16:27 +01:00

36 lines
666 B
Objective-C

//
// MPFactorialTerm.m
// MathKit
//
// Created by Kim Wittenburg on 15.11.14.
// Copyright (c) 2014 Kim Wittenburg. All rights reserved.
//
#import "MPFactorialTerm.h"
@implementation MPFactorialTerm
- (instancetype)initWithTerm:(MPTerm *)term
{
self = [super init];
if (self) {
NSAssert(term != nil, @"term must not be nil.");
_term = term;
}
return self;
}
- (NSDecimalNumber *)doEvaluation:(NSError *__autoreleasing *)error
{
NSDecimalNumber *value = [self.term evaluate:error];
if (!value) {
return nil;
}
return [[NSDecimalNumber alloc] initWithDouble:tgamma(value.doubleValue + 1)];
}
@end