[Updated] Goldman Sachs Aptitude Test Questions and Answers
Practice List of TCS Digital Coding Questions !!!
Take 50+ FREE!! Online Data Interpretation Mock test to crack any Exams.

Program Discussion :: Basics

Home > Programs > Basics

289 / 279

Write a function to accept a number 'n' and
a)if n is negative then return -1.
b)if n is positive and perfect number then return sqrt(n).
c)if n is positive and not a perfect no. then return n(n+1)/2

Answer:

public class CheckNumber {
    static int sum=0;
    static boolean isPerfact(int n) {
        for(int i=1;i

Asked In :: Virtusa

Post Your Answer Here:

Language:

Post Your Reply Here: