Last active
January 23, 2023 13:12
-
-
Save TGITS/52ea62c1d517093eb5965f2433c9d36a to your computer and use it in GitHub Desktop.
Exemple de fichier de secript jshell créé à partir d'une sauvegarde de snippets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.*; | |
import java.math.*; | |
import java.net.*; | |
import java.nio.file.*; | |
import java.util.*; | |
import java.util.concurrent.*; | |
import java.util.function.*; | |
import java.util.prefs.*; | |
import java.util.regex.*; | |
import java.util.stream.*; | |
import java.util.stream.Collectors; | |
import java.util.stream.IntStream; | |
int sumOfDividers(int value){ | |
return IntStream.rangeClosed(1, value).filter(i -> value % i == 0).sum(); | |
} | |
var maxItems = 100; | |
System.out.println("Perfect Numbers up to : " + maxItems); | |
String list = IntStream.rangeClosed(1, maxItems).filter(num -> sumOfDividers(num) == 2 * num).mapToObj(i -> ((Integer) i).toString()).collect(Collectors.joining(", ")); | |
System.out.println(">> " + list); | |
void print(boolean b) { System.out.print(b); } | |
void print(char c) { System.out.print(c); } | |
void print(int i) { System.out.print(i); } | |
void print(long l) { System.out.print(l); } | |
void print(float f) { System.out.print(f); } | |
void print(double d) { System.out.print(d); } | |
void print(char s[]) { System.out.print(s); } | |
void print(String s) { System.out.print(s); } | |
void print(Object obj) { System.out.print(obj); } | |
void println() { System.out.println(); } | |
void println(boolean b) { System.out.println(b); } | |
void println(char c) { System.out.println(c); } | |
void println(int i) { System.out.println(i); } | |
void println(long l) { System.out.println(l); } | |
void println(float f) { System.out.println(f); } | |
void println(double d) { System.out.println(d); } | |
void println(char s[]) { System.out.println(s); } | |
void println(String s) { System.out.println(s); } | |
void println(Object obj) { System.out.println(obj); } | |
void printf(java.util.Locale l, String format, Object... args) { System.out.printf(l, format, args); } | |
void printf(String format, Object... args) { System.out.printf(format, args); } | |
print("Hello world!"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment