Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
BMO1 Q1 1994
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
""" Starting with any three digit number n (such as n = 625), we can obtain a new number f(n), which is equal to the sum of the three digits of n, their three three products in pairs, and the product of all three digits. Find all three digit numbers such that the ratio n/f(n)=1. """ A = 100 def get_digit(number, n): return number // 10**n % 10 while A<1000: a = get_digit(A, 2) b = get_digit(A, 1) c = get_digit(A, 0) d = a + b + c + a*b + a*c + b*c + a*b*c if d == A: print(A) A = A + 1
[
+
]
Show input
Absolute running time: 0.3 sec, cpu time: 0.28 sec, memory peak: 6 Mb, absolute service time: 0,31 sec
edit mode
|
history
|
discussion
199 299 399 499 599 699 799 899 999