Skip to content

Instantly share code, notes, and snippets.

View bijay-shrestha's full-sized avatar
👨‍🎓
MSCS Compro

Bijay Shrestha bijay-shrestha

👨‍🎓
MSCS Compro
View GitHub Profile

GitHub

Add Github repository to local drive

echo "# error-handling" >> README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin https://github.com/bijay-shrestha/error-handling.git
/**
* * Write a function named minDistance that returns the smallest distance between two factors of a number.
* *
* * For example, consider 13013 = 1*7*11*13. Its factors are 1, 7, 11, 13 and 13013.
* * minDistance(13013) would return 2 because the smallest distance between any two factors is 2 (13 - 11 = 2).
* *
* * As another example, minDistance (8) would return 1 because the factors of 8 are 1, 2, 4, 8
* * and the smallest distance between any two factors is 1 (2 – 1 = 1).
* *
* * The function signature is
/**
* * Write a function named largestAdjacentSum that iterates through an array computing the sum of adjacent
* * elements and returning the largest such sum. You may assume that the array has at least 2 elements.
* *
* * If you are writing in Java, the function signature is
* * int largestAdjacentSum(int[ ] a)
* *
* * Examples:
* *
* * if a is return
/**
* Define an array to be a Martian array if the number of 1s is greater than the number of 2s and no two adjacent elements are equal.
*
* Write a function named isMartian that returns 1 if its argument is a Martian array; otherwise it returns 0.
*
* If you are programming in Java or C#, the function signature is
* int isMartian(int[ ] a)
*
* There are two additional requirements.
*
/**
*
* It is a fact that there exist two numbers x and y such that x! + y! = 10!.
* Write a method named solve10 that returns the values x and y in an array.
* The notation n! is called n factorial and is equal to n * n-1 * n-2 * … 2 * 1, e.g., 5! = 5*4*3*2*1 = 120.
*
*/
package com.hawa.practice;
/**
*
* * An array is defined to be complete if the conditions (a), (d) and (e) below hold.
* * a. The array contains even numbers
* * b. Let min be the smallest even number in the array.
* * c. Let max be the largest even number in the array.
* * d. min does not equal max
* * e. All numbers between min and max are in the array
* *
* * For example {-5, 6, 2, 3, 2, 4, 5, 11, 8, 7} is complete because
/**
* * A balanced array is defined to be an array where for every value n in the array, -n also is in the
* * array. For example {-2, 3, 2, -3} is a balanced array. So is {-2, 2, 2, 2}. But {-5, 2, -2} is not because 5
* * is not in the array.
* *
* * Write a function named isBalanced that returns 1 if its array argument is a balanced array. Otherwise
* * it returns 0.
* *
* * If you are programming in Java or C#, the function signature is
* * int isBalanced (int [ ] a);
/**
*
* * An Evens number is an integer whose digits are all even. For example 2426 is an Evens number
* * but 3224 is not.
* *
* * Write a function named isEvens that returns 1 if its integer argument is an Evens number otherwise it
* * returns 0.
* *
* * The function signature is
* * int isEvens (int n)
/**
*
* * An array is defined to be a Magic array if the sum of the primes in the array is equal to the first
* * element of the array.
* *
* * If there are no primes in the array, the first element must be 0. So {21, 3, 7, 9, 11 4, 6} is a Magic array
* * because 3, 7, 11 are the primes in the array and they sum to 21 which is the first element of the array.
* *
* * {13, 4, 4, 4, 4} is also a Magic array because the sum of the primes is 13 which is also the first element.
* *
/**
* * Get Maximum Element value from the given array.
*/
package com.basic.practice;
import lombok.extern.slf4j.Slf4j;
@Slf4j
public class MaxNumberInArray {