Check if a number can be written as sum of three consecutive integers | CPP Program to check if a number can be written as sum of three consecutive integer . ; function to check if a number can be written as sum of three consecutive integers . ; if n is multiple of 3 ; else print " - 1" . ; Driver Program
#include <bits/stdc++.h> NEW_LINE using namespace std ; void checksum ( int n ) { if ( n % 3 == 0 ) cout << n / 3 - 1 << " ▁ " << n / 3 << " ▁ " << n / 3 + 1 ; else cout << " - 1" ; } int main ( ) { int n = 6 ; checksum ( n ) ; return 0 ; }