summaryrefslogtreecommitdiff
path: root/java
diff options
context:
space:
mode:
authorSanto Cariotti <sancn@live.com>2017-07-23 19:59:49 +0200
committerSanto Cariotti <sancn@live.com>2017-07-23 19:59:49 +0200
commit73d0deef8bad64e542f73982789bebeb50e347a4 (patch)
tree43a31a963ce4a44afb7b50293557ce214415c13a /java
parent25a2f54e4771032c788fe96ef9d58315ac0b33a5 (diff)
clear
Diffstat (limited to 'java')
-rw-r--r--java/somme.java35
1 files changed, 0 insertions, 35 deletions
diff --git a/java/somme.java b/java/somme.java
deleted file mode 100644
index c1da9d5..0000000
--- a/java/somme.java
+++ /dev/null
@@ -1,35 +0,0 @@
-import java.util.Scanner;
-
-public class HelloWorld {
- private static boolean pari(int n) {
- return (n % 2) == 0;
- }
-
- private static int sequenza(int n, boolean pollatz, int tCollatz) {
- int m = ((pollatz) ? 5 : 3), tot = 1;
-
- while(n != 1) {
- n = (pari(n)) ? n/2 : n*m+1;
-
- tot++;
-
- if(tCollatz != -1 && tot > tCollatz)
- break;
- }
-
- return tot;
- }
-
- public static void main(String[] args) {
- Scanner in = new Scanner(System.in);
- int N1 = in.nextInt(), N2 = in.nextInt(), tot = 0, collatz;
-
- for(int i = N1; i <= N2; i++) {
- collatz = sequenza(i, false, -1);
- if(sequenza(i, true, collatz) < collatz )
- tot++;
- }
-
- System.out.println(tot);
- }
-}