Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
solution to problem #3 from projecteuler.net
Language:
Ada
Assembly
Bash
C#
C++ (gcc)
C++ (clang)
C++ (vc++)
C (gcc)
C (clang)
C (vc)
Client Side
Clojure
Common Lisp
D
Elixir
Erlang
F#
Fortran
Go
Haskell
Java
Javascript
Kotlin
Lua
MySql
Node.js
Ocaml
Octave
Objective-C
Oracle
Pascal
Perl
Php
PostgreSQL
Prolog
Python
Python 3
R
Rust
Ruby
Scala
Scheme
Sql Server
Swift
Tcl
Visual Basic
Layout:
Vertical
Horizontal
//Project Euler #3 using System; using System.Collections.Generic; using System.Linq; using System.Text.RegularExpressions; namespace Rextester { public class Program { public static void Main(string[] args) { long n = 600851475143; for(int i=1; i <= Math.Sqrt(n)+1; i++) if(n % i == 0 && IsPrime(i)) Console.Write(" "+i); } public static bool IsPrime(int number) { if(number == 1 || number == 2) return true; for(int i=2; i<=Math.Sqrt(number)+1; i++) if(number % i == 0) return false; return true; } } }
Show compiler warnings
[
+
]
Show input
Compilation time: 1.08 sec, absolute running time: 0.53 sec, cpu time: 0.09 sec, average memory usage: 16 Mb, average nr of threads: 3
edit mode
|
history
|
discussion
1 71 839 1471 6857