Random rnd = new Random();
int randomNumberTo10 = rnd.nextInt(10); // 0 - 9-ig generálhat számokat, 10-et sosem generál
// Javascript
function getRandomInt(max) {
return Math.floor(Math.random() * max);
}
console.log(getRandomInt(10)); // Integer values: [0, 9]
import random
random = random.randrange(0,10)
# Random Number Generator
## Small Python Game
## You will win if you guess a number greater than the system generated number
import random
uNum = int(input("Enter a number between 0 and 100: "))
sNum = random.randint(0,100)
if uNum > sNum:
print("You Win!!!")
else:
print("Try Again!!!")
print("Your Number:", uNum, "
System Number:", sNum)
System.out.println(Math.random());
import random # Import random libary
minimum = 1 # Minimum number
maximum = 10 # Maximum number
random_number = random.randint(minimum,maximum) # Generate random number
print(random_number) # Print random number
const rndInt = Math.floor(Math.random() * 6) + 1
console.log(rndInt)
// C program to generate random numbers
#include <stdio.h>
#include <stdlib.h>
#include<time.h>
// Driver program
int main(void)
{
// This program will create different sequence of
// random numbers on every program run
// Use current time as seed for random generator
srand(time(0));
for(int i = 0; i<4; i++)
printf(" %d ", rand());
return 0;
}
Random rnd = new Random();
int randomNumberTo10 = rnd.nextInt(10); // 0 - 9-ig generálhat számokat, 10-et sosem generál