Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
sum of digits is prime
# Function to check if the number is TRUE or FALSE checkPrime <- function(number) { if (number == 2) { TRUE } else if (any(number %% 2:(number-1) == 0)) { FALSE } else { TRUE } } # Function to return sum of the digits digitsum <- function(x) sum(floor(x / 10^(0:(nchar(x) - 1))) %% 10) # loop from 10 to 200 num=10 while (num <= 200) { # Check the sum of digits here n=num s=0 while (n > 0) { r = n %% 10 s = s + r n = n %/% 10 } # check if prime if(checkPrime(s)){ message("sum=",s," => num=",num) } # Update num value num = num+1 }
run
|
edit
|
history
|
help
0
Mobile-Sprite-image-Interval
Polynomial Regression with Interaction
Functions for partial factorials, factorials, binomial coeffs., & rows of Pascale's Triangle.
First R
R1
untitled
Hernani
Gab1B-nb
Example R Code
ECO Stat