Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Square-Triangle Numbers
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
""" This program finds numbers that are both square and triangular. A square number can be written in the form n*n. A triangular number can be written in the form a(a+1)/2. With some manipulation of the two equations, you can generate the formua that is used. """ from math import sqrt a:int = 0 while True: a = a+1 b = 8 * a * a + 1 c = sqrt(b) if c % 1 == 0: print(a*a)
[
+
]
Show input
edit mode
|
history
|
discussion