FACT function
PRO BASIC
The FACT function in Jspreadsheet Formulas Pro is a mathematical function that calculates the factorial of a number. Essentially, it multiplies the given number by every integer less than it down to 1. For example, the factorial of 5 (expressed as 5!) would be 54321, which equals 120. This function is used when you want to perform such calculations within your Jspreadsheet.
Documentation
Returns the factorial of a number.
Category
Math and trigonometry
Syntax
FACT(x)
| Parameter | Description | 
|---|---|
x | 
The non-negative integer for which to calculate the factorial. | 
Behavior
The FACT function calculates the factorial of a given number. A factorial of a number is the product of all positive integers less than or equal to that number. Here's how the FACT function handles different inputs:
- Numbers: The function computes the factorial of the given number. For example, 
FACT(5)returns120because5*4*3*2*1equals120. - Empty cells: If the 
FACTfunction is applied to an empty cell, it treats the cell as0and returns1because the factorial of0is1. - Text: If the function is applied to a cell that contains text, it returns a 
#VALUE!error because the function requires a numerical argument. - Booleans: If the function is applied to a cell that contains a boolean value (
TRUEorFALSE), it treatsTRUEas1andFALSEas0and calculates the factorial accordingly. - Errors: If the function is applied to a cell that contains an error, it returns the same error.
 
Common Errors
| Error | Description | 
|---|---|
#VALUE! | 
This error is returned when the function is applied to a cell that contains non-numeric data. | 
#NUM! | 
This error is returned when the function is applied to a negative number or a number larger than 170 because the factorial function is only defined for non-negative integers and the result of factorial calculations for numbers larger than 170 exceeds the maximum limit for numbers in Jspreadsheet. | 
Best practices
- Always ensure that the argument to the
 FACTfunction is a non-negative integer. The function returns an error for negative numbers and non-integer values.- Be cautious when using the
 FACTfunction with large numbers. Factorial calculations grow rapidly and can exceed the maximum limit for numbers in spreadsheets for numbers larger than170.- Avoid using the
 FACTfunction on cells that may contain non-numeric data to prevent#VALUE!errors.- Use error handling functions like
 ISNUMBERorIFERRORto handle potential errors when using theFACTfunction in complex formulas.
Usage
A few examples using the FACT function.
FACT(5)    // Returns 120 - factorial of 5  
FACT(0)    // Returns 1 - factorial of 0 is defined as 1  
FACT(1)    // Returns 1 - factorial of 1 is 1  
FACT(170)  // Returns the largest factorial value supported by Jspreadsheet  
FACT(-3)   // Returns #NUM! - factorial not defined for negative numbers  
Interactive Spreadsheet Demo
<html>
<script src="https://jspreadsheet.com/v11/jspreadsheet.js"></script>
<script src="https://jsuites.net/v5/jsuites.js"></script>
<link rel="stylesheet" href="https://jsuites.net/v5/jsuites.css" type="text/css" />
<link rel="stylesheet" href="https://jspreadsheet.com/v11/jspreadsheet.css" type="text/css" />
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Material+Icons" />
<script src="https://cdn.jsdelivr.net/npm/@jspreadsheet/formula-pro/dist/index.min.js"></script>
<div id="spreadsheet"></div>
<script>
// Set your JSS license key (The following key only works for one day)
jspreadsheet.setLicense('MGQ0ODk2NTdiZDNkMTBmNDlhMDFjYzE3NjgwZTdlY2U4OTg1YmY3ZmEzMzNhMDQxMzc5NTQ2OWNiYmE3NTFjMDNiOGYyODk4YTZjODc0YWU2MzYyOTU4NWFkMzdiMjZjNjg1ODEwYjY0MjYzZTQ4ODQwMmZkZmEyNWQwMzEwOWEsZXlKamJHbGxiblJKWkNJNklpSXNJbTVoYldVaU9pSktjM0J5WldGa2MyaGxaWFFpTENKa1lYUmxJam94TnpZeU16QTJORFEwTENKa2IyMWhhVzRpT2xzaWFuTndjbVZoWkhOb1pXVjBMbU52YlNJc0ltTnZaR1Z6WVc1a1ltOTRMbWx2SWl3aWFuTm9aV3hzTG01bGRDSXNJbU56WWk1aGNIQWlMQ0p6ZEdGamEySnNhWFI2TG1sdklpd2lkMlZpWTI5dWRHRnBibVZ5TG1sdklpd2liRzlqWVd4b2IzTjBJbDBzSW5Cc1lXNGlPaUl6TkNJc0luTmpiM0JsSWpwYkluWTNJaXdpZGpnaUxDSjJPU0lzSW5ZeE1DSXNJbll4TVNJc0ltTm9ZWEowY3lJc0ltWnZjbTF6SWl3aVptOXliWFZzWVNJc0luQmhjbk5sY2lJc0luSmxibVJsY2lJc0ltTnZiVzFsYm5Seklpd2lhVzF3YjNKMFpYSWlMQ0ppWVhJaUxDSjJZV3hwWkdGMGFXOXVjeUlzSW5ObFlYSmphQ0lzSW5CeWFXNTBJaXdpYzJobFpYUnpJaXdpWTJ4cFpXNTBJaXdpYzJWeWRtVnlJaXdpYzJoaGNHVnpJaXdpWm05eWJXRjBJbDBzSW1SbGJXOGlPblJ5ZFdWOQ==');
// Set the extensions
jspreadsheet.setExtensions({ formula });
// Create a new spreadsheet
jspreadsheet(document.getElementById('spreadsheet'), {
  worksheets: [{
    data: [
    [
        "Number",
        "Factorial"
    ],
    [
        0,
        "=FACT(A2)"
    ],
    [
        3,
        "=FACT(A3)"
    ],
    [
        5,
        "=FACT(A4)"
    ],
    [
        7,
        "=FACT(A5)"
    ]
]
  }]
});
</script>
</html>
import React, { useRef } from "react";
import { Spreadsheet, Worksheet, jspreadsheet } from "@jspreadsheet/react";
import formula from "@jspreadsheet/formula-pro";
import "jsuites/dist/jsuites.css";
import "jspreadsheet/dist/jspreadsheet.css";
// Set license
jspreadsheet.setLicense('MGQ0ODk2NTdiZDNkMTBmNDlhMDFjYzE3NjgwZTdlY2U4OTg1YmY3ZmEzMzNhMDQxMzc5NTQ2OWNiYmE3NTFjMDNiOGYyODk4YTZjODc0YWU2MzYyOTU4NWFkMzdiMjZjNjg1ODEwYjY0MjYzZTQ4ODQwMmZkZmEyNWQwMzEwOWEsZXlKamJHbGxiblJKWkNJNklpSXNJbTVoYldVaU9pSktjM0J5WldGa2MyaGxaWFFpTENKa1lYUmxJam94TnpZeU16QTJORFEwTENKa2IyMWhhVzRpT2xzaWFuTndjbVZoWkhOb1pXVjBMbU52YlNJc0ltTnZaR1Z6WVc1a1ltOTRMbWx2SWl3aWFuTm9aV3hzTG01bGRDSXNJbU56WWk1aGNIQWlMQ0p6ZEdGamEySnNhWFI2TG1sdklpd2lkMlZpWTI5dWRHRnBibVZ5TG1sdklpd2liRzlqWVd4b2IzTjBJbDBzSW5Cc1lXNGlPaUl6TkNJc0luTmpiM0JsSWpwYkluWTNJaXdpZGpnaUxDSjJPU0lzSW5ZeE1DSXNJbll4TVNJc0ltTm9ZWEowY3lJc0ltWnZjbTF6SWl3aVptOXliWFZzWVNJc0luQmhjbk5sY2lJc0luSmxibVJsY2lJc0ltTnZiVzFsYm5Seklpd2lhVzF3YjNKMFpYSWlMQ0ppWVhJaUxDSjJZV3hwWkdGMGFXOXVjeUlzSW5ObFlYSmphQ0lzSW5CeWFXNTBJaXdpYzJobFpYUnpJaXdpWTJ4cFpXNTBJaXdpYzJWeWRtVnlJaXdpYzJoaGNHVnpJaXdpWm05eWJXRjBJbDBzSW1SbGJXOGlPblJ5ZFdWOQ==');
// Set the extensions
jspreadsheet.setExtensions({ formula });
export default function App() {
    // Spreadsheet array of worksheets
    const spreadsheet = useRef();
    // Worksheet data
    const data = [
    [
        "Number",
        "Factorial"
    ],
    [
        0,
        "=FACT(A2)"
    ],
    [
        3,
        "=FACT(A3)"
    ],
    [
        5,
        "=FACT(A4)"
    ],
    [
        7,
        "=FACT(A5)"
    ]
];
    // Render component
    return (
        <Spreadsheet ref={spreadsheet}>
            <Worksheet data={data} />
        </Spreadsheet>
    );
}
<template>
    <Spreadsheet ref="spreadsheet">
        <Worksheet :data="data" />
    </Spreadsheet>
</template>
<script>
import { Spreadsheet, Worksheet, jspreadsheet } from "@jspreadsheet/vue";
import "jsuites/dist/jsuites.css";
import "jspreadsheet/dist/jspreadsheet.css";
import formula from "@jspreadsheet/formula-pro";
// Set license
jspreadsheet.setLicense('MGQ0ODk2NTdiZDNkMTBmNDlhMDFjYzE3NjgwZTdlY2U4OTg1YmY3ZmEzMzNhMDQxMzc5NTQ2OWNiYmE3NTFjMDNiOGYyODk4YTZjODc0YWU2MzYyOTU4NWFkMzdiMjZjNjg1ODEwYjY0MjYzZTQ4ODQwMmZkZmEyNWQwMzEwOWEsZXlKamJHbGxiblJKWkNJNklpSXNJbTVoYldVaU9pSktjM0J5WldGa2MyaGxaWFFpTENKa1lYUmxJam94TnpZeU16QTJORFEwTENKa2IyMWhhVzRpT2xzaWFuTndjbVZoWkhOb1pXVjBMbU52YlNJc0ltTnZaR1Z6WVc1a1ltOTRMbWx2SWl3aWFuTm9aV3hzTG01bGRDSXNJbU56WWk1aGNIQWlMQ0p6ZEdGamEySnNhWFI2TG1sdklpd2lkMlZpWTI5dWRHRnBibVZ5TG1sdklpd2liRzlqWVd4b2IzTjBJbDBzSW5Cc1lXNGlPaUl6TkNJc0luTmpiM0JsSWpwYkluWTNJaXdpZGpnaUxDSjJPU0lzSW5ZeE1DSXNJbll4TVNJc0ltTm9ZWEowY3lJc0ltWnZjbTF6SWl3aVptOXliWFZzWVNJc0luQmhjbk5sY2lJc0luSmxibVJsY2lJc0ltTnZiVzFsYm5Seklpd2lhVzF3YjNKMFpYSWlMQ0ppWVhJaUxDSjJZV3hwWkdGMGFXOXVjeUlzSW5ObFlYSmphQ0lzSW5CeWFXNTBJaXdpYzJobFpYUnpJaXdpWTJ4cFpXNTBJaXdpYzJWeWRtVnlJaXdpYzJoaGNHVnpJaXdpWm05eWJXRjBJbDBzSW1SbGJXOGlPblJ5ZFdWOQ==');
// Set the extensions
jspreadsheet.setExtensions({ formula });
export default {
    components: {
        Spreadsheet,
        Worksheet,
    },
    data() {
        // Worksheet data
        const data = [
    [
        "Number",
        "Factorial"
    ],
    [
        0,
        "=FACT(A2)"
    ],
    [
        3,
        "=FACT(A3)"
    ],
    [
        5,
        "=FACT(A4)"
    ],
    [
        7,
        "=FACT(A5)"
    ]
]
        return {
            data
        };
    }
}
</script>
import { Component, ViewChild, ElementRef } from "@angular/core";
import jspreadsheet from "jspreadsheet";
import * as formula from "@jspreadsheet/formula-pro";
// Set your JSS license key (The following key only works for one day)
jspreadsheet.setLicense('MGQ0ODk2NTdiZDNkMTBmNDlhMDFjYzE3NjgwZTdlY2U4OTg1YmY3ZmEzMzNhMDQxMzc5NTQ2OWNiYmE3NTFjMDNiOGYyODk4YTZjODc0YWU2MzYyOTU4NWFkMzdiMjZjNjg1ODEwYjY0MjYzZTQ4ODQwMmZkZmEyNWQwMzEwOWEsZXlKamJHbGxiblJKWkNJNklpSXNJbTVoYldVaU9pSktjM0J5WldGa2MyaGxaWFFpTENKa1lYUmxJam94TnpZeU16QTJORFEwTENKa2IyMWhhVzRpT2xzaWFuTndjbVZoWkhOb1pXVjBMbU52YlNJc0ltTnZaR1Z6WVc1a1ltOTRMbWx2SWl3aWFuTm9aV3hzTG01bGRDSXNJbU56WWk1aGNIQWlMQ0p6ZEdGamEySnNhWFI2TG1sdklpd2lkMlZpWTI5dWRHRnBibVZ5TG1sdklpd2liRzlqWVd4b2IzTjBJbDBzSW5Cc1lXNGlPaUl6TkNJc0luTmpiM0JsSWpwYkluWTNJaXdpZGpnaUxDSjJPU0lzSW5ZeE1DSXNJbll4TVNJc0ltTm9ZWEowY3lJc0ltWnZjbTF6SWl3aVptOXliWFZzWVNJc0luQmhjbk5sY2lJc0luSmxibVJsY2lJc0ltTnZiVzFsYm5Seklpd2lhVzF3YjNKMFpYSWlMQ0ppWVhJaUxDSjJZV3hwWkdGMGFXOXVjeUlzSW5ObFlYSmphQ0lzSW5CeWFXNTBJaXdpYzJobFpYUnpJaXdpWTJ4cFpXNTBJaXdpYzJWeWRtVnlJaXdpYzJoaGNHVnpJaXdpWm05eWJXRjBJbDBzSW1SbGJXOGlPblJ5ZFdWOQ==');
// Set the extensions
jspreadsheet.setExtensions({ formula });
@Component({
    standalone: true,
    selector: "app-root",
    template: `<div #spreadsheet></div>`
})
export class AppComponent {
    @ViewChild("spreadsheet") spreadsheet: ElementRef;
    // Worksheets
    worksheets: jspreadsheet.worksheetInstance[];
    // Create a new data grid
    ngAfterViewInit() {
        // Create spreadsheet
        this.worksheets = jspreadsheet(this.spreadsheet.nativeElement, {
            worksheets: [{
                data: [
    [
        "Number",
        "Factorial"
    ],
    [
        0,
        "=FACT(A2)"
    ],
    [
        3,
        "=FACT(A3)"
    ],
    [
        5,
        "=FACT(A4)"
    ],
    [
        7,
        "=FACT(A5)"
    ]
]
            }]
        });
    }
}