Generate a list of n consecutive composite numbers ( An interesting method ) | CPP program to print n consecutive composite numbers . ; function to find factorial of given number ; Prints n consecutive numbers . ; Driver program to test above function
#include <iostream> NEW_LINE using namespace std ; unsigned long long int factorial ( unsigned int n ) { unsigned long long int res = 1 ; for ( int i = 2 ; i <= n ; i ++ ) res *= i ; return res ; } void printNComposite ( int n ) { unsigned long long int fact = factorial ( n + 1 ) ; for ( int i = 2 ; i <= n + 1 ; ++ i ) cout << fact + i << " ▁ " ; } int main ( ) { int n = 4 ; printNComposite ( n ) ; return 0 ; }