Skip to content

Java-GAD/easy-algorithms-teo321

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Review Assignment Due Date

basic-algorithms

Sum of Numbers up to a Given Number

Problem Description:

Given a positive integer n, write a Java program to calculate the sum of all positive integers from 1 to n, inclusive.

Function Signature:

public int calculateSum(int n)

Input:

An integer n where 1 <= n <= 10^4.

Output:

An integer representing the sum of all positive integers from 1 to n.

Factorial of a Number

Problem Description:

Write a Java program that computes the factorial of a positive integer entered by the user. Display the result.

Function Signature:

public int calculateFactorial(int n)

Input:

An integer n where n >= 0.

Output:

An integer representing the factorial of n. Prime Number Check

Problem Description:

Develop a Java program that checks whether a given positive integer is a prime number or not. Display an appropriate message.

Function Signature:

public boolean isPrime(int n)

Input:

An integer n where n >= 2.

Output:

A boolean value indicating whether n is prime or not (true for prime, false for non-prime).

Generating Fibonacci Sequence

Problem Description:

Write a Java program to generate the first n terms of the Fibonacci sequence and display them.

Function Signature:

public int[] generateFibonacci(int n)

Input:

An integer n where n >= 1.

Output:

An array of integers representing the first n terms of the Fibonacci sequence.

Drawing Shapes with Stars

Problem Description:

Create a Java program that draws a pattern of asterisk (*) characters based on user input for the number of rows and columns.

Function Signature:

public void drawPattern(int rows, int columns)

Input:

Two integers, rows and columns, where rows and columns are both greater than or equal to 1.

Output:

Display a pattern of asterisk (*) characters with the specified number of rows and columns.

Find the Largest and Smallest Number

Problem Description:

Write a Java program that finds the largest and smallest numbers from a list of integers entered by the user. Display both results.

Function Signature:

public void findMinMax(int[] numbers)

Input:

An array of integers, numbers, where the length of the array is at least 1.

Output:

Display the largest and smallest numbers from the given list.

FizzBuzz

Problem Description:

Write a Java program that prints the numbers from 1 to n. But for multiples of 3, print "Fizz" instead of the number, and for the multiples of 5, print "Buzz". For numbers which are multiples of both 3 and 5, print "FizzBuzz".

Function Signature:

public void fizzBuzz(int n)

Input

An integer n where n >= 1.

Output:

Print the numbers from 1 to n based on the FizzBuzz rules.

1. Loops problems

2. Arrays problem:

3. Hashing problems

4. Two pointer technique

5. Sliding window

6. Stack problems

7. Binary search

8. Linked List

About

easy-algorithms-teo321 created by GitHub Classroom

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages