## HTC Global Services Interview Question for Software Developers

Country: India
Interview Type: Written Test

Comment hidden because of low score. Click to expand.
1
of 1 vote

// ZoomBA
def prime_factors( n ){
#( primes, factors ) = lfold ( [2:n+1] , [ list() , dict() ] ) -> {
cur = \$.o ; partial_primes = \$.p.0 ; partial_factors = \$.p.1
is_prime_cur = !exists ( partial_primes ) :: {  \$.o /? cur }
continue ( !is_prime_cur )
partial_primes += cur
multiplicty = 0
for ( x = n ; cur /? x ; x/= cur ){ multiplicty += 1 }
if ( multiplicty > 0 ){ partial_factors[cur] = multiplicty }
\$.p
}
factors
}
println( prime_factors ( 36 ) )

We have made it a bit human readable. Feedback of inhuman came.
Next post, we would optimize it for math lovers.

Comment hidden because of low score. Click to expand.
1
of 1 vote

// ZoomBA
def prime_factors( n ){
select ( lfold ( [2:n+1] , dict() ) -> {
continue ( exists ( \$.p.keySet ) :: {  \$.o /? \$.\$.o } )
\$.p[\$.o] = 0
for ( x = n ; \$.o /? x ; x/= \$.o ){ \$.p[\$.o] += 1 }
\$.p
} ) :: { \$.o.value > 0 }
}
println( prime_factors ( 36 ) )

Making it inhuman, and thus lovers of succinct syntax should like it.

Comment hidden because of low score. Click to expand.
0
of 0 vote

#include<iostream>
using namespace std;
int main()
{
int x;
cin>>x;
int n=x;
int i=2;
while(n!=1)
{
while(n%i==0)
{
cout<<i<<endl;
n=n/i;
}
i++;

}

}

Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

### Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

### Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.