Represent K ^ N as the sum of exactly N numbers | C ++ program to represent K ^ N as the sum of exactly N numbers ; Function to print N numbers whose sum is a power of K ; Printing K ^ 1 ; Loop to print the difference of powers from K ^ 2 ; Driver code
#include <bits/stdc++.h> NEW_LINE #define ll  long long int NEW_LINE using namespace std ; void print ( ll n , ll k ) { cout << k << " ▁ " ; for ( int i = 2 ; i <= n ; i ++ ) { ll x = pow ( k , i ) - pow ( k , i - 1 ) ; cout << x << " ▁ " ; } } int main ( ) { ll N = 3 , K = 4 ; print ( N , K ) ; return 0 ; }