Skip to content

Commit

Permalink
Merge pull request #11 from TesseractCoding/master
Browse files Browse the repository at this point in the history
mpr
  • Loading branch information
JayantGoel001 authored Dec 2, 2020
2 parents f973083 + decd5ba commit 77cd29b
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 2 deletions.
9 changes: 9 additions & 0 deletions .all-contributorsrc
Original file line number Diff line number Diff line change
Expand Up @@ -1127,6 +1127,15 @@
"contributions": [
"code"
]
},
{
"login": "ErzaTitania-2001",
"name": "@2001!",
"avatar_url": "https://avatars3.githubusercontent.com/u/59911272?v=4",
"profile": "https://github.com/ErzaTitania-2001",
"contributions": [
"code"
]
}
],
"repoType": "github",
Expand Down
1 change: 1 addition & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
<td align="center"><a href="https://github.com/JayantGoel001"><img src="https://avatars0.githubusercontent.com/u/54479676?v=4" width="100px;" alt=""/><br /><sub><b>Jayant Goel</b></sub></a><br /><a href="https://github.com/TesseractCoding/NeoAlgo/commits?author=JayantGoel001" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/Gaurav6982"><img src="https://avatars0.githubusercontent.com/u/49642550?v=4" width="100px;" alt=""/><br /><sub><b>Gaurav</b></sub></a><br /><a href="https://github.com/TesseractCoding/NeoAlgo/commits?author=Gaurav6982" title="Code">💻</a></td>
<td align="center"><a href="http://techsfortalk.me"><img src="https://avatars3.githubusercontent.com/u/64386187?v=4" width="100px;" alt=""/><br /><sub><b>Ashutosh_K_Sah</b></sub></a><br /><a href="https://github.com/TesseractCoding/NeoAlgo/commits?author=ashu-cybertron" title="Code">💻</a></td>
<td align="center"><a href="https://github.com/ErzaTitania-2001"><img src="https://avatars3.githubusercontent.com/u/59911272?v=4" width="100px;" alt=""/><br /><sub><b>@2001!</b></sub></a><br /><a href="https://github.com/TesseractCoding/NeoAlgo/commits?author=ErzaTitania-2001" title="Code">💻</a></td>
</tr>
</table>

Expand Down
4 changes: 2 additions & 2 deletions Java/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ _add list here_
- [Check for Subsequence](cp/CheckForSubSequence.java)
- [Factorial of large numbers](cp/Factorial_large_numbers.java)
- [Happiness Problem (cp sets question)](cp/HappinessProblem.java)
- [Prime Number With Recursion](cp/PrimeRecursion.java)
- [Prime Number without Recursion](cp/Prime.java)

## Cryptography

Expand Down Expand Up @@ -98,7 +100,6 @@ _add list here_

## Dynamic Programming


- [Kandane Algorithm](dp/Kadane_Algorithm.java)
- [Longest common subsequence](dp/LCS.java)
- [Maximum sum rectangle of 2D array](dp/MaximumSumRectangle.java)
Expand All @@ -107,7 +108,6 @@ _add list here_
- [Coin Change Problem Using DP](dp/CoinChangeUsingDp.java)
- [Rectangle Cutting Using DP](dp/Rectangle_cutting.java)


## Blockchain

_add list here_
Expand Down
29 changes: 29 additions & 0 deletions Java/cp/Prime.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// check whether a number is Prime or not without recursion

import java.util.Scanner;
class Prime
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
System.out.print("Enter a number : ");
int n=(int)Math.abs(sc.nextInt());
int c=0;
for(int i=2;i<n;i++)
if (n%i==0)
c++;
System.out.println(n+((c==0)?" is a Prime Number." :" is not a Prime Number."));
}
}

// Contributed By ErzaTitani-2001

/*
Sample Input and Output :
Input :
Enter a number : 13
Output :
13 is a Prime Number.
Space Complexity : O(1)
Time Complexity : O(n)
*/
36 changes: 36 additions & 0 deletions Java/cp/PrimeRecursion.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// check whether a number is Prime or not with recursion

import java.util.Scanner;
class PrimeRecursion
{
public static int prime(int n,int div)
{
if(div<n)
{ if(n%div!=0)
prime(n,div+1);
else
return 0;
}
return 1;
}
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
System.out.print("Enter a number : ");
int n=(int)Math.abs(sc.nextInt());
int c=prime(n,2);
System.out.println(n+((c!=0)?" is a Prime Number." :" is not a Prime Number."));
}
}

// Contributed By ErzaTitani-2001

/*
Sample Input and Output :
Input :
Enter a number : 13
Output :
13 is a Prime Number.
Space Complexity : O(n)
Time Complexity : O(n)
*/

0 comments on commit 77cd29b

Please sign in to comment.