CPP
cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <iostream>
using namespace std;
// This function returns a boolean value
bool isGapful(int n){
// This n2 is for the divisor
int n2 = n;
// Note that I used while true here.
while (true){
n2 = n2%10;
// And ending while with break;
if (n2<9){
break;
}
}
// Now I add the last digit
n2 = n2 + n%10;
// Hon fu's !(n%n2) works too,
// I'm just coding more explicit here.
if (n%n2==0){
return true;
}else{
return false;
}
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run