T = gets.to_i
def prime(input)
flag = 0
return puts "Not prime" if input == 1
for n in 2..(Math.sqrt(input))
if input%n == 0
flag = 1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
namespace CombineSequenceNumbers | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
string input; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# method for finding happy or sad number | |
def happy_or_sad(input) | |
result = 0 | |
repeated_number = Hash.new(); | |
while(!repeated_number.has_key?(input)) | |
temp = 0 | |
repeated_number[input] = 0 | |
input.each do |i| | |
temp = temp + (i.to_i * i.to_i) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
namespace HappyAndSadNumbers | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
string input; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void main(String[] args) { | |
String[][] spiral = new String[3][3]; | |
spiral[0][0] = "1"; | |
spiral[0][1] = "2"; | |
spiral[0][2] = "3"; | |
spiral[1][0] = "4"; | |
spiral[1][1] = "5"; | |
spiral[1][2] = "6"; | |
spiral[2][0] = "7"; |
NewerOlder