Java
public class MathUtils {

  public boolean isPrime(int n) {
    for (int i=2; i*i<=n; i++) {
      if (n%i==0) {
        return true;
      }
    }
    return false;
  }

}
C++
#include <iostream>
#include <string>

int main()
{
  std::string name;
  std::cout << "Your name: ";
  std::cin >> name;
  std::cout << "Hello, "
            << name << "\n";
  return 0;
}
Prolog
mother(trude, sally).

father(tom, sally).
father(tom, erica).
father(mike, tom).

sibling(X, Y) :- parent(Z, X), parent(Z, Y).

parent(X, Y) :- father(X, Y).
parent(X, Y) :- mother(X, Y).

Do you know these 3 languages?

Sign up to try them all.

Solve language-specific tasks to taste different languages.