## Facebook Interview Question

Software Engineer Interns**Country:**United States

**Interview Type:**Phone Interview

```
func cubeAllDigits(in number:Int) -> Int {
var sum = 0
var left = number
while left > 0 {
let x = left % 10
sum += x * x * x
left = (left - x) / 10
}
return sum
}
print(cubeAllDigits(in: 2)) // 8
print(cubeAllDigits(in: 153)) // 153
print(cubeAllDigits(in: 103)) // 28
print(cubeAllDigits(in: 555555)) // 750
```

{ static void Main(string[] args)

{

double res;

for (int i = 1; i < 10; i++)

{

for (int j = 1; j < 10; j++)

{

for (int k = 1; k < 10; k++)

{

res = Math.Pow(i, 3) + Math.Pow(j, 3) + Math.Pow(k, 3);

if ( res == int.Parse(i.ToString() + j.ToString() + k.ToString()) )

{

Console.WriteLine(res);

}

}

}

}

Console.ReadLine();

}}

Hope this helps

- PeyarTheriyaa November 09, 2018