VMWare Inc Interview Question for SDETs


Country: India
Interview Type: Phone Interview




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

we can convert into it's decimal representation and check in O(sqrt(N)) if it's prime or not. Just to speed up things a little, we can get rid of even numbers just by checking the rightmost bit.

- Darkhan.Imangaliev May 26, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
1
of 1 vote

public  static void  checkPrime(String str){
        // convert to decimal
        int x=Integer.parseInt(str,2);
        System.out.print(" Input number:" + x );
        // check if mod is
        if (x ==2 ) { System.out.println(" Prime number"); return ;}
        for(int i =2; i <= Math.sqrt(x); i++ )
            if (x %i == 0) {
                System.out.println(" No Prime number:" + i );
                return ;
            }
            System.out.println(" Prime number");

    }

- mdz June 02, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

public  static void  checkPrime(String str){
        // convert to decimal
        int x=Integer.parseInt(str,2);
        System.out.print(" Input number:" + x );
        // check if mod is
        if (x ==2 ) { System.out.println(" Prime number"); return ;}
        for(int i =2; i <= Math.sqrt(x); i++ )
            if (x %i == 0) {
                System.out.println(" No Prime number:" + i );
                return ;
            }
            System.out.println(" Prime number");

    }

- Anonymous June 02, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

import sys

bin_no = raw_input()
num = int(bin_no, 2)
a = 2

if bin_no[-1:] == '0':
    print 'Not a Prime number'
    sys.exit()

while num > a:
    if num % a == 0:
        print 'Not Prime'
        break
    a += 1
    
else:
    print 'Prime'

- Suraj Bhatia October 15, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

import sys

bin_no = raw_input()
num = int(bin_no, 2)
a = 2

if bin_no[-1:] == '0':
    print 'Not a Prime number'
    sys.exit()

while num > a:
    if num % a == 0:
        print 'Not Prime'
        break
    a += 1
    
else:
    print 'Prime'

- surajbhatia.SB October 15, 2016 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

If number is below than 6, check directly. If not use algorithm 6K+-1. Where K is positive number

- Anonymous June 11, 2018 | Flag Reply
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.


Add a Comment
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.

Learn More

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.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More